aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/parser/codemodel.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move the shiboken-generator source aroundFriedemann Kleint2025-11-241-1594/+0
| | | | | | | | | THIS COMMIT WAS GENERATED BY A SCRIPT Task-number: PYSIDE-962 Task-number: PYSIDE-1587 Change-Id: I58b05c3d05606efb6303193f2d7f907a0ab5741b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken6/code model: Add a type category roughly modelled after libclang's ↵Friedemann Kleint2025-09-171-0/+5
| | | | | | | | | | | | CXType_Kind Use what clang considers to be the "canonical" type for a category enumeration. This is useful for follow-up changes to simplify type resolution. Pick-to: 6.10 Change-Id: Ic9f23308cf6bf4b5b29f3c2fff119cba58f3ac1e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6/code model: _TypeDefModelItem: Add accessFriedemann Kleint2025-09-171-1/+11
| | | | | Change-Id: I45eaf7f67588fd7c25ff2eab959d2470e62c6e87 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Remove unused code paths for Q_ENUMFriedemann Kleint2025-09-151-8/+1
| | | | | | | | | | | There was apparently some code path checking whether an enum had a Q_ENUM declaration; but the value was not used and the clang parser no longer determines it. Remove it. Pick-to: 6.10 6.9 6.8 Task-number: PYSIDE-323 Change-Id: I486c68e0980a03ee8c6a9b8e5656e5697df63c4e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6/code model: Add utility function returning the qualified name as ↵Friedemann Kleint2025-09-151-0/+5
| | | | | | | | | string Pick-to: 6.10 6.9 6.8 Task-number: PYSIDE-323 Change-Id: I7388966bf35cd4f8d569049464450cc0ceba9615 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Allow for building with Clang 14 (Yocto)Friedemann Kleint2025-04-301-1/+15
| | | | | | | | | | | | | | | Replace clang functions clang_CXXMethod_isCopyAssignmentOperator() and clang_CXXMethod_isMoveAssignmentOperator() by a manual check function depending on clang version. Amends 6410710ab9580f71ab58ac38e67d74bbde5dbce4. Complements b887919ea244a057f15be9c1cdc652538e3fe9a0. Fixes: PYSIDE-3091 Task-number: PYSIDE-3004 Pick-to: 6.9 Change-Id: I18b073e7fe572ffe8b4635a26cec45b0b6adbac3 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Port to Qt include styleFriedemann Kleint2025-03-271-3/+3
| | | | | | | | | Replace the Qt forwarding headers by the .h files. This brings down the dependency list by approx 6%. Pick-to: 6.9 Change-Id: Iaa57400fd20600b940119a6016041b885a68d207 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Handle further class special functionsFriedemann Kleint2025-02-111-0/+6
| | | | | | | | | | | | | | | | - Obtain (copy) assignment operators from libclang and introduce another function type for assignments from other types, which do not impact copy-constructibility. - Handle deleted assignment/move assignment. - Add function query operators. - Disable adding of implicit copy constructor when assignment/move is present. Testing follows in a subsequent patch. Task-number: PYSIDE-3004 Change-Id: I11451bada3f970fb76e80b8ee76e1406441bb9db Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Fix some clang-tidy warningsFriedemann Kleint2025-02-031-1/+1
| | | | | | | | | | | | - Fix invocation of static functions - Use std::any, range-based for where applicable - Use std::make_shared instead of new - Replace QByteArrayLiteral() by literal - Use const-ref to avoid copies Pick-to: 6.8 Change-Id: Iec864bd6eee8fb06f5afd122084a9e0f551ff8f1 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Fix clang-tidy warning about using std::any_of instead of loopsFriedemann Kleint2024-06-241-5/+4
| | | | | Change-Id: Ic85973e29870456bf422a3ac75fd9d68524ad886 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Fix static analysis warningsFriedemann Kleint2024-06-241-6/+6
| | | | | | | | | | | | | | | | | | - Initialize variables - Use auto * - Use const references to prevent copies - Remove const from function returns - Remove repeated return types - Fix else after return/throw - Make functions const/static where appropriate - Add missing override - Fix some invocations of static methods - Fix some int types (qsizetype) to avoid lossy conversions - Minor cleanups - Remove some macros Change-Id: I414b8451703b136f135383289de49e743e84fb3a Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Extract common C++ function attributesFriedemann Kleint2024-04-171-66/+6
| | | | | | | | | | | | | | | | Extract attributes common to C++ functions from AbstractMetaFunction's attributes to a flags type in codemodel_enums.h for re-use in AbstractMetaFunction, FunctionModelItem and AddedFunction. A lot of boolean setters and getters can then be removed and the flags easily transferred from code model to the meta language code. Task-number: PYSIDE-2602 Pick-to: 6.7 Change-Id: I9da1bb0d70051cd6bb3113290e8ccedfe4d13908 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Remove unused function modificationsFriedemann Kleint2024-04-171-11/+0
| | | | | | | | | As a drive-by, fix the "public" modification flag to be 4. Task-number: PYSIDE-2602 Pick-to: 6.7 Change-Id: I5bacc2bf17e5307df02b9e6d6adadc09d04a9ded Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Port the CodeModel::find*() helpers to QAnyStringViewFriedemann Kleint2023-11-271-41/+25
| | | | | | | | As a drive-by, replace some old find predicates by lambdas. Task-number: PYSIDE-2537 Change-Id: I2fbb3f86f87a497f2aa7d22d666ae2d3aa641364 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Fix some clang-tidy warningsFriedemann Kleint2023-09-201-6/+4
| | | | | | | | | | | | | | | | - narrowing conversion qsizetype->int - Repeating return type for default-constructed values - Make methods const - Add missing references - Use range-based for - Use Q_DISABLE_COPY_MOVE where applicable - Initialize variables - Remove unused function parameters Pick-to: 6.6 6.5 Change-Id: I65290fe2dab5283a5cbbf6f82c413c3cf294f1bd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Add the underlying type to AbstractMetaEnumFriedemann Kleint2023-06-201-0/+10
| | | | | | Task-number: PYSIDE-1735 Change-Id: I7733c93baffa1396d5a43b68069e9e8848e9fe49 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6/clang: Record scope resolution of arguments/function returnFriedemann Kleint2023-04-281-0/+24
| | | | | | | | | | | | | Add a flag indicating whether a type was specified with a leading "::" (scope resolution). Such parameters previously caused the function to rejected due to the "::TypeName" not being found. The type resolution added for clang 16 strips these qualifiers though, so, the information needs to be stored. Task-number: PYSIDE-2288 Pick-to: 6.5 5.15 Change-Id: I27d27c94ec43bcc4cb3b79e6e9ce6706c749a1e9 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Refactor code model classesFriedemann Kleint2023-04-281-1/+100
| | | | | | | | | | Use member initialization and use base class constructors. De-inline constructors to avoid bloat. Pick-to: 6.5 5.15 Task-number: PYSIDE-2288 Change-Id: Iea0474d4972d9bf5cfa501ac04d829e9801e98e3 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Port from QSharedPointer to std::shared_ptrFriedemann Kleint2023-01-051-10/+10
| | | | | | | Task-number: QTBUG-109570 Change-Id: Iabdafb0a5ab211e32c1bbf7face78fd5102a49b9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6/generator: Fix CMake UNITY_BUILD (jumbo)Friedemann Kleint2022-12-161-20/+1
| | | | | | | | - Use a string literal for "::" - Add a header for debug helpers Change-Id: I605a00fea1b936032afa93d9be45b7da31d42473 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Purge remaining uses of old Qt string literalsFriedemann Kleint2022-11-221-3/+5
| | | | | | | | | | Amends a3e882b06eda8f9a63cf3834a99640034775269b. Pick-to: 6.4 Task-number: QTBUG-98434 Change-Id: I23ad60d6e4201aa2d8dbf3fa8892d3df3c56c5fc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Port some loop variables to qsizetypeFriedemann Kleint2022-10-131-6/+6
| | | | | | | | Where possible, used range-based for. Otherwise, use qsizetype for loop variables. Change-Id: I4773bee8468ce73722656ec73845369b7d40d4cd Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Port from qAsConst() to std::as_const()Friedemann Kleint2022-10-131-1/+1
| | | | | | | | qAsConst() will be deprecated in Qt 6.5. Task-number: QTBUG-99313 Change-Id: Ibc7c2e26b0e52cec905a406ef081e0b99bcce50f Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Propagate C++ enum deprecationFriedemann Kleint2022-08-221-0/+24
| | | | | | | | | | | | | Add AbstractMetaEnum::isDeprecated() and AbstractMetaEnumValue::isDeprecated() which are set by the clang parser for deprecated enums and values (for example, QVariant::Type). As a drive-by, streamline the debug output of the enums, removing the repretitive EnumValue type name. Task-number: PYSIDE-1735 Change-Id: I4c98965ca4a948f5f084f781914194e5bf4d4ea2 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Implement the spaceship comparison operator of C++ 20Friedemann Kleint2022-06-211-1/+8
| | | | | | | | Synthesize all comparison operators if one is found in the code model. Task-number: QTBUG-103757 Change-Id: I78fbcd93bc4cd172266f9dd0dbb2ebcf3a8bb7f2 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Use SPDX license identifiersLucie Gérard2022-05-271-28/+3
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: I065150015bdb84a3096b5b39c061cf0a20ab637d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Migrate from QLatin1Char to UTF-16 char literalsFriedemann Kleint2022-04-251-3/+3
| | | | | | | | | Preparing for the deprecation of QLatin1Char in 6.4. Task-number: QTBUG-98434 Pick-to: 6.3 6.2 Change-Id: I8bc92aa9f4e6dbfcb12d2025c5a1e760ab4f0d7f Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Fix comparison operators in namespacesFriedemann Kleint2022-03-221-0/+25
| | | | | | | | | | | | | | | | Change qtbase/e7fd9a9f4ab1fcc017174d6d7760c731857b89fc introduced some mixed flag operators in Qt which caused compile errors. They should be ignored by traverseOperatorFunction() since they cannot be attributed to any class, but traverseOperatorFunction() was only called for the global namespace. Fix by calling it for operator functions in namespaces as well. Task-number: QTBUG-99948 Pick-to: 6.2 Change-Id: I57419563f10f1a0d33aea027a166119f969bca5d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Port code to use size() instead of count() of Qt containersFriedemann Kleint2022-03-171-2/+2
| | | | | | | | | | | count() will be deprecated. Fix some integer types in loops and modernize code in changed lines. Pick-to: 6.2 Change-Id: Idf21927661ea6c8866ee36e7c623043271e21620 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Add internal flags to AbstractMetaFunctionFriedemann Kleint2021-12-161-0/+10
| | | | | | | | | | | | Add some internal flags useful mainly for documentation indicating: - whether AbstractMetaBuilder removed operator arguments, which is useful for the documentation. - the function was inherited from a (container) template - the function was declared a hidden friend Task-number: PYSIDE-1106 Change-Id: Id31b1448a084f45ab7b3191b28c952d0226816e7 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Implement enum search by value in code modelFriedemann Kleint2021-11-051-0/+93
| | | | | | | | | | | | | | | | | | | | | | | | Replace (currently unused) AbstractMetaBuilder::searchForEnumScope() by _ScopeModelItem::findEnumByValue() returning an enum and the fully qualified name. This function is intended for resolving enum values used as default values for functions taking int where the underlying enum is not known. As opposed to old code, all parts of a (partially) qualified name are checked for a match to ensure no mismatches of equally named values. Another advantage is that also enum values that are not in the type system are found. The function returns the fully qualified name (also including the enum name for non-class type enums). Task-number: PYSIDE-1691 Pick-to: 6.2 Change-Id: I89ebfdf8435470c626cfdee4fc0d0738cc3fc195 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Store pointer enclosing scope in code model itemsFriedemann Kleint2021-11-041-0/+17
| | | | | | | | | | | Store a flat pointer to the enclosing class in _ScopeModelItem. This is needed for implementing enum resolution in the code model directly. Task-number: PYSIDE-1691 Pick-to: 6.2 Change-Id: Ic44edb5f121503990044faa4bc6db65220d81c51 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Store a pointer to base classes in the code modelFriedemann Kleint2021-11-041-8/+0
| | | | | | | | | | | | Extend the struct _ClassModelItem::BaseClass by an optional ClassModelItem pointing to the class directly and populate it by the builder. This is needed for implementing enum resolution in the code model directly. Task-number: PYSIDE-1691 Pick-to: 6.2 Change-Id: I1abce6cbb777384ccbb187e79c09b5cb9da1563b Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Handle enums without valuesFriedemann Kleint2021-10-181-0/+18
| | | | | | | | | | | | shiboken used to ignore enumerations without values assuming they were just forward declaration of an enum classes. It turns out that there are such cases (QCborTag). To fix this, add empty enums always and replace them by the ones with values. Task-number: PYSIDE-1691 Pick-to: 6.2 Change-Id: I5de69f86ed45bd9f239e6d6017e7dc4a554f5378 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Fix increment/decrement operatorsFriedemann Kleint2021-06-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | For classes that have increment/decrement operators (++/--), shiboken6 generated operators +=/-= ( __iadd__/__isub__) by calling them n times. This was mainly intended for iterators. However, when both operator++/-- and operator+=/-= were present (as introduced by qtdeclarative/f8f31dd0e1f9425ba272691c79e719ebc4bcfb94 for QJSPrimitiveValue), duplicate code and errors were generated. This requires filtering of the operator functions. Introduce a separate function type for increment/decrement operators and remove them if operators +=/-= were found. Also, when both prefix and postfix version of the increment/decrement operators are found, remove one. Extend existing class IntWrapper from libsample for testing. Add explanatory comment and use prefix increment. Pick-to: 6.1 Change-Id: I0f8a0c79a6f74974ba327d21f35fff74962ffd3a Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Add constructors of base classes imported via "using"Friedemann Kleint2021-03-011-0/+15
| | | | | | | | | | | | | Parse "using" declarations in the clang builder using some code from the base class determination algorithm. Resolve them to struct UsingMember containing the base class and the member name in the metabuilder and check whether any base constructors are imported via "using". Add them as functions like the default constructor. Change-Id: I121a70f0591c6d1e6f9daedfb653206c49c07a3f Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Move C++ access specifiers into a global enumFriedemann Kleint2021-02-171-17/+26
| | | | | | | | | | | | | | | | | | | | | Extract the AcessPolicy enum from the code model into a global enum and remove the access specifiers from AbstractMetaAttributes. AbstractMetaField and AbstractMetaEnum get access()/setAccess() functions and no longer need to inherit AbstractMetaAttributes which removes the attributes that do not apply to them. AbstractMetaFunction gets access()/setAccess() functions, too, and handling for remembering the original access before modifications. AbstractMetaAttributes::originalAttributes can then be removed since it is not used otherwise. Simplify the code accordingly. Change-Id: Ie4529fc753f127975b5c56ee07b27419802361d6 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Improve detection of default/copy constructabilityFriedemann Kleint2021-02-171-0/+6
| | | | | | | | | | | Add support for deleted functions. Extend the checks for default constructability by checks for fields and base classes. Refactor the check for copy constructability to recursively check on base classes. Remove functionality for adding private copy constructors which was apparently unused. Change-Id: I8105f277699d6121aa8aa193d9cb16bf8133e901 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Make more functions static using clang tidyFriedemann Kleint2021-01-231-1/+1
| | | | | | | | | Apply the fix created by clang tidy' -wreadability-convert-member-functions-to-static warning with some manual correction. Change-Id: I394bd96881fa25dbcb7a725b79d10395fcbb8676 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Add missing break statementsFriedemann Kleint2021-01-221-0/+2
| | | | | | | | Fix an oversight of 6a1a08cfaf11ad38612e59cb1d56160160504ec8. Pick-to: 6.0 Change-Id: Iba09b4c631132f7c50ab6b2321b9e93a61c26650 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Determine function types in the code modelFriedemann Kleint2020-12-111-0/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | Extend the _FunctionModelItem function type enumeration by operator types and determine them by name or from clang. Split the bitwise operators into shift and other bitwise operators for stresm operator detection. Similarly, add operator type values to AbstractMetaFunction::FunctionType and replace the isOperator() checks accordingly. Remove the unused isOtherOperator() function. Rename AbstractMetaFunction::isNormal() to needsReturnType() for clarity. Rewrite the binary operator search in AbstractMetaBuilder by checks based on enumeration value and rewrite traverseOperatorFunction to return a bool so that shift operators are found when stream operator is not applicable. Rewrite the function query functions of AbstractMetaClass to also use the enumeration values. Pick-to: 6.0 Change-Id: I06cc2deefcd8a158f83c95513a7962de467f7f2a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Replace QVector by QListFriedemann Kleint2020-11-251-1/+1
| | | | | | | | | | | | | | | | Change AbstractMetaClass::templateArguments() to return TypeEntries (const TypeEntry *) instead non-const. Remove redundant typedef OverloadData::MetaFunctionList. Use existing typedefs in some places. Add new typedefs for MetaObjectBuilder::EnumValues and AbstractMetaFunctionCList. Change-Id: Ia241b5fbe54d60ea57175fb1f6c844604e066a3d Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Split out class TypeInfoFriedemann Kleint2020-11-051-378/+13
| | | | | | | | | | This is the first step towards using it in AddedFunction as well, replacing AddedFunction::TypeInfo. Change list accessors to return const-ref on this occasion. Change-Id: I78a7be0b3cb738b859519b7fbff8ed024fb46106 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Rename shiboken2 to shiboken6Friedemann Kleint2020-10-281-0/+1608
Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I4cb5ee4c8df539546014b08202a7b1e98ed3ff07 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>