aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename shiboken2 to shiboken6Friedemann Kleint2020-10-281-1244/+0
| | | | | | | | 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>
* shiboken2: Handle typedefs of template parameters within templatesFriedemann Kleint2020-10-271-11/+47
| | | | | | | | | | | | | | | | | | Typedefs of template parameters like template <class T> class QList { using reference = T&; are reported as "type-parameter-0-0" by clang. Resolve that to the proper name of the template parameter in the clang builder. Also, these typeinfo results must not be cached since the same CXType is used for parameters of unrelated templates. Rename the createTypeInfoHelper() function to createTypeInfoUncached() for clarity and introduce a cacheable parameter. Change-Id: I2b21a4dfdd8d86cf36497832837c21f37cb86518 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-221-1/+6
|\ | | | | | | Change-Id: Id0fc76666bbdb254a833eeb6909a0874b2611bf3
| * shiboken2: Add namespace variablesFriedemann Kleint2020-09-211-1/+6
| | | | | | | | | | | | | | | | | | | | They were ignored in the code parser. Take them into account and add a test. Task-number: PYSIDE-1224 Change-Id: I3baca95556129d695db294fdcc1ad92fc831672d Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Remove most QT_VERSION checksFriedemann Kleint2020-09-031-4/+0
| | | | | | | | | | | | | | | | | | As a drive by, adapt to changed values of QMetaObject::Call. Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: Ic55a5da910c9ef022af3dedf749f80153f519ebf Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Start porting away from QStringRefFriedemann Kleint2020-08-191-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | QStringRef will be replaced by QStringView. Remove most usages or use auto. This will require a 2nd cleanup removing its usages from the QXmlStreamReader code once this has landed in qtbase. Task-number: QTBUG-84319 Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: I2885df70d5f883bcad7bb3a31618fc1d63116df5 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-07-201-1/+4
|\| | | | | | | Change-Id: I5c6913b4eea9d6e11415011753e556eca18c5532
| * Fix libsample/photon test for Qt 6 / WindowsFriedemann Kleint2020-07-201-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code model was seeing photon.h:93: template class LIBSAMPLE_API TemplateBase<IdentityType>; as complete class definitions, shadowing the previous template definition. Add some processing removing them. Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: If0f28feeb6e3ff8c064e8853784240695f79e0b4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken2: Fix build with MSVC2019Friedemann Kleint2020-07-151-3/+3
| | | | | | | | | | | | | | | | | | | | std::string_view::iterator is not char *, apparently. Amends 1bfd77c92d78c3861d0c09068e6c353020a510f4. Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: I5946bca2e71b82e1b30cdbfaff3bdfee875e60ca Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-07-131-0/+13
|\| | | | | | | Change-Id: I509b55363c29639cd29bfbc012c4bda3a4d008e5
| * shiboken2: Re-add support for parsing Q_PROPERTYFriedemann Kleint2020-07-131-0/+13
| | | | | | | | | | | | | | | | | | | | | | Following how qdoc does it, define Q_PROPERTY as a static assert with the stringified macro content in a ','-operator and parse it with clang. Task-number: PYSIDE-1019 Change-Id: Idcf53f1cd1c1cb29f4320444f446e9abad33d251 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | shiboken2: Fix exception handling for C++ 17Friedemann Kleint2020-07-101-12/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | throw() has been removed in C++17, causing testmodifyfunction to fail for Qt 6. noexcept(false) should be used instead. noexcept() takes a constexpr value, which we cannot easily compute. Add handling for the simple true, false cases by checking the code snippet. Task-number: PYSIDE-904 Change-Id: Icb9f8770d2de2b9f218bfa72e516e360c0cd65aa Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | shiboken2/clangparser: Use std::string_view for code snippet extractionFriedemann Kleint2020-07-101-34/+5
|/ | | | | | | | std: :string_view was added in C++ 17 and fits the purpose. Remove some outdated code for Clang < 5 on this occasion. Change-Id: I787f736679421c9080a6cabdef1616efb2c512e9 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken2/clangparser: Refactor code snippet extraction handlingFriedemann Kleint2020-07-091-16/+19
| | | | | | | | | | | | | | | | Code snippets resulting from macro expansion have a 0 range. Detect this first thing and return an empty snippet before starting to convert file names and reading files. For that purpose, use a CXFile instead of a QString in SourceLocation. For all other cases, output a verbose warning. Provide a function to obtain the file name from a CXFile with caching in the builder. Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: Ie30563f5b25d0d21b3a1ceb0c9da37cfc8d808dd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Resolve typedef'ed base classesFriedemann Kleint2020-06-121-6/+31
| | | | | | | | Add a resolve function. Change-Id: If85c1de402f212e4c16b18e2ec8ad97075ac3cff Fixes: PYSIDE-1327 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Fix duplicated template parameters of functions with non-type ↵Friedemann Kleint2020-05-191-0/+2
| | | | | | | | | | template parameters Clear the instantiations in case clang parsing failed Task-number: PYSIDE-1296 Change-Id: Ia1e07d633f45338fc8f35efa46c752a62a51ad76 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Add support for template type aliasesFriedemann Kleint2020-05-181-9/+58
| | | | | | | | | | | | | In Qt 6 as of May 2020, this is used to alias QList to QVector: template<typename T> using QList = QVector<T> which shiboken needs to handle. Introduce a new code model item for this and add it to the resolver. Task-number: PYSIDE-904 Change-Id: I9e558635e843b60d44c0ceaaaa68b09b50c25c9f Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Allow for parsing headers under system include pathsFriedemann Kleint2020-04-161-2/+17
| | | | | | | | | Extend the <system-include> element for a trailing slash to indicate an absolute path against which a file is matched. Change-Id: I9557e26b941a7d5d5cab575cd978c158c6859b97 Fixes: PYSIDE-1267 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Friedemann Kleint2020-02-191-8/+28
|\ | | | | | | Change-Id: I827c17bc77d4da46abc6db2a91a8cc9296b4c0e0
| * shiboken: Handle typedef'ed enumsFriedemann Kleint2020-02-181-8/+28
| | | | | | | | | | | | | | | | | | | | | | Treat "typedef enum {} Name" as "enum Name". Clang actually provides type information for these cases, use it (taking care not to break real anonynous enumerations) and skip the repetitive definition of the elaborated type. Fixes: PYSIDE-1228 Change-Id: Icaf0450f3fea3ba9f06737e351b56e6e5df0749a Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | shiboken: Add a way of specifying system includes to be parsedFriedemann Kleint2019-12-051-0/+12
| | | | | | | | | | | | Task-number: PYSIDE-454 Change-Id: I9302cf74544315875a65bc09b75741c7fe6399e8 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | shiboken: Handle inline namespacesFriedemann Kleint2019-12-031-0/+15
|/ | | | | | | | | Check the attribute as returned by the clang parser and add it to the handling of the visible attribute of namespaces. Fixes: PYSIDE-990 Change-Id: I3428b59d6d9a5d60dd95db5fc0640772bd3985c8 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Refactor the logic deciding whether headers should be parsedFriedemann Kleint2019-11-151-31/+48
| | | | | | | | | | | - Use cstring and prefix by std - Split the functions into base name and comparison functions - Use a non-type template to pass the size for startsWith() - Split out visitHeader() for clarity Task-number: PYSIDE-454 Change-Id: I48e2a9ae5fead892c20d9729cb90d61ff5d7fb0a Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Replace 'typedef' by 'using'Friedemann Kleint2019-06-251-6/+4
| | | | | | | | Apply Fixits by Qt Creator with some amendments. Remove iterator types by using auto instead. Change-Id: I8a75323da6ae5cdcc6b67af8be9376408953986b Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Make it possible to extend namespacesFriedemann Kleint2019-05-221-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt has some modules, where functions and classes are added to namespaces of other modules. For example, QtGui adds the free functions mightBeRichText() and convertFromPlainText() to the "Qt" namespace and Qt3DQuick adds a namespace "Quick" to the namespace "Qt3DCore" started in Qt3DCore. Shiboken was unable to handle this since the name of the index constant was derived from the namespace name and would thus clash. Also, all code model items from the base module would be re-generated into the extended namespace. To fix this: - No longer join namespace code model items in clang builder. - Search for pre-existing namespaces in traverseNamespace() before creating a new one, continuing populating it. - Add a "files" attribute taking a regular expression to match header names to the namespace type entry, making it possible to restrict code model items by files when extending namespaces (as otherwise, all base items are again added). - Add "extends" attribute specifying the package name of the namespace to extend, which will be used as base type in CPython. - Disambiguate the SBK indexes of namespaces and the init_ functions by adding the module name. Change-Id: Ib552e878911942fa4d52d2bb0c6695e5b2c4c341 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Extend exception specificationFriedemann Kleint2018-09-171-8/+20
| | | | | | | | | | | | | Change boolean 'noexcept' flag into an enumeration that indicates whether a function throws, is 'noexcept' or the behavior is unknown. This makes it easier to implement an 'auto' mode for exception handling. Task-number: PYSIDE-62 Change-Id: I4e5405863e5af2a54f3528ba5eb5c51d3929703d Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Add support for type aliases (using)Friedemann Kleint2018-07-261-10/+20
| | | | | | | | | | | | | | | QAbstractRayCaster is the first class in Qt to use type aliases: using Hits = QVector<QRayCasterHit>; Treat them as typedefs if a canonical type can be obtained for them. This requires adding some simplification of the canonical types obtained for standard containers. Task-number: PYSIDE-751 Change-Id: I521a8b02d3c8cb89e4f72a817fbacc5955041570 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Add exception specification to clang parserFriedemann Kleint2018-07-241-0/+8
| | | | | | | | | For exception handling, calls into C++ might need to wrapped in try/catch. Detect noexcept functions for which this can be omitted. Task-number: PYSIDE-62 Change-Id: I37aced91ace184edf211a457a60c131d516a4037 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix some clang-tidy warnings in shibokenFriedemann Kleint2018-07-231-2/+1
| | | | | | | | | | | | | | | | | - 'else if' after return/break/continue - Use const ref for complex arguments passed by value where possible - Fix 'if (foo) delete foo' to 'delete foo' - Use container.isEmpty() instead of container.size() in checks - Use ' = default' for trivial constructors/destructors - Use range based for where possible - Complete constructor initializer lists - Fix invocations of static methods - Replace some reinterpret_cast by static_cast - Remove unused variables/fields - Use initializer lists for return types Change-Id: Id5b44a2f9d429f66ef069d532a1cd31df796d38e Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Cache TypeInfo in clangbuilderFriedemann Kleint2018-07-231-6/+18
| | | | | | | | | Add a cache containing the TypeInfo for the CXType structs. Task-number: PYSIDE-672 Change-Id: Ibd0b5bb3f01fa507a65ded8f121c12a10aa7c401 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Move detection of template arguments to ClangBuilderFriedemann Kleint2018-07-111-0/+57
| | | | | | | | | | | | | | | | Obtain the template arguments from Clang and fall back to parsing the type name where this is not possible (which may be the case inside a template declaration). The string-based formatting and re-parsing of the type in AbstractMetaBuilder::translateType() can then be removed, opening the way to passing up more complex types from Clang into the MetaBuilder. Task-number: PYSIDE-672 Change-Id: I43ff285c5f3720319bf40c65b1c27302ef1b934e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Improve const handlingFriedemann Kleint2018-07-111-70/+38
| | | | | | | | | | | | | | - Use new enum in code. - Rewrite the Clang type parsing to make use of it. - Adapt some typesystem files. This enables the distinction between "int *" and "int *const" and fixes the signatures from "int const &" to the more common "const int&". Task-number: PYSIDE-672 Change-Id: Ic1bff0015188c32f53d0e6f347b1523254cb7e4f Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Fix handling of deleted functionsFriedemann Kleint2018-07-061-0/+12
| | | | | | | | | | | Check the cursor availability to detect deleted functions. This fixes the build of the Qt 5.12 API, which for the first time has a Q_DISABLE(QCBorStreamReader) in a public section, causing a copy constructor to be reported. Task-number: PYSIDE-487 Change-Id: I31ba0103cf612a4238c0e282ffcfeeab29df97d1 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Handle enum class forward declarationsFriedemann Kleint2018-07-061-1/+4
| | | | | | | | | | | | Add the enumeration to the scope stack only if it actually has values. This occurs for the first time in Qt 5.12, which introduces a forward declaration of enum class QCborSimpleType at src/corelib/kernel/qmetatype.h:65. Task-number: PYSIDE-487 Change-Id: I5798eb8e47bcd4d21dc554dc5cdd257c7163ca90 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken/ClangBuilder: Fix nested qualified namesFriedemann Kleint2018-06-011-1/+22
| | | | | | | | | | | The qualified name was obtained by splitting by "::", which would result in "std::list<std::string>" -> ("std", "list<std", string>"). Fix by splitting up to first '<' or '(' only. Task-number: PYSIDE-672 Change-Id: I9d790535e877da251a5b6c352dc550e4077877bd Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Change license from all the filesCristian Maureira-Fredes2018-05-031-1/+1
| | | | | | | | | | | | | | | | | Removing the word 'project' from all the headers, and changing the PySide reference from the examples to Qt for Python: The following line was used inside the source/ and build_scripts/ directory: for i in $(grep -r "the Qt for Python project" * |grep -v "pyside2-tools" | awk '{print $1}' | sed 's/:.*//g');do sed -i 's/the\ Qt\ for\ Python\ project/Qt\ for\ Python/g' $i;done and the following line was used inside the examples/ directory: for i in $(grep -r "of the PySide" * |grep -v "pyside2-tools" | awk '{print $1}' | sed 's/:.*//g');do sed -i 's/of\ the\ PySide/of\ the\ Qt\ for\ Python/g' $i;done Change-Id: Ic480714686ad62ac4d81c670f87f1c2033d4ffa1 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Rename PySide references to Qt for PythonCristian Maureira-Fredes2018-04-271-1/+1
| | | | | | | | | When referring to the project one should use "Qt for Python" and for the module "PySide2" Change-Id: I36497df245c9f6dd60d6e160e2fc805e48cefcae Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Use enum values from ClangFriedemann Kleint2018-04-191-1/+26
| | | | | | | | | | | | | | Remove a lot of ugly value parsing code in favor of clang_getEnumConstantDeclValue() and clang_getEnumConstantDeclUnsignedValue() depending on the type. Introduce a class EnumValue containing a union of qint64 and quint64 values to represent signed/unsigned values correctly and use that in the code model and meta language classes. Change-Id: If2efb7cfd560237907678b8f6fdfb0bc689c0c93 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Detect class enums by Clang entirelyFriedemann Kleint2018-04-191-3/+42
| | | | | | | | | | | | | | The Clang function clang_EnumDecl_isScoped() tells whether an enum is a class, so, there is no need to specify that in the typesystem. Use that information to pass it up to the metalang classes and revert the parts of 44cb6c51e6c3b43376f284941454dc8c13b81c3f that added it to the type system. Task-number: PYSIDE-487 Change-Id: Ie10885f74168821d0307e91b6f1f7f3f30dd074b Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix system header inclusions for proper support of C primitive typesAlexandru Croitor2018-01-151-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | In order for GL types like GLint64 to be available on macOS, the macOS-specific system header "gltypes.h" has to be parsed by libclang. Before this change, shiboken skipped parsing system headers (except for gl.h) because there are issues when trying to parse C++ std headers (ostream for example). The file "gltypes.h" contains the typedef declarations for GL numeric types. A few other system headers like "cstdint" are also needed (which contain the actual typedefs from int32_t to int for example). A few different system headers are also needed on Linux (also for GL -> numeric typedefs). This system header exclusion mechanism is far from a clean solution, but it seems like current versions of libclang do not provide enough preprocessor information to be able to limit the parsing to specific chunks of code (for example everything included by gltypes.h), thus we need to limit ourselves to exclusion by file paths. Change-Id: I58c151e2cb083e16f7cafb3dc9df2d757442bb59 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken/Clang parser: Add information about override/finalFriedemann Kleint2017-12-011-0/+10
| | | | | Change-Id: I0f1bad0567ae928d4117e7785e7788d9efd551c2 Reviewed-by: Christian Tismer <tismer@stackless.com>
* CodeModel: Handle access of inherited classesFriedemann Kleint2017-09-251-2/+3
| | | | | | | | | | | | | | Store the access of the base class in the code model. Remove protected/private base classes in the abstract meta builder as otherwise invalid code will be generated for classes like QAbstract3DGraph : public QWindow, protected QOpenGLFunctions when the protected hack is not in use (on Windows). Task-number: PYSIDE-487 Change-Id: I5bc2dad16f903da86e6e41450c2f9a76726ac028 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Do not consider gl.h a system include file (all platforms)Friedemann Kleint2017-09-131-3/+19
| | | | | | | | | | Amends db904f8e9ed06eac37151c9a8b955c63c1eb8a46 to apply to all platforms since the issue is also present on Linux. Task-number: PYSIDE-516 Change-Id: I564506f6aefc26e95beae90d95643553eba5dbff Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Windows: Do not consider gl.h a system include fileFriedemann Kleint2017-09-041-1/+19
| | | | | | | | Amends 10453490629859a01048d0b21688d6617279eeaf. Task-number: PYSIDE-516 Change-Id: Ie4bc2008669e4e34bedf0575de3ff75adbc2413e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Use information about Constructor/Destructor functions from ClangFriedemann Kleint2017-05-291-8/+30
| | | | | | | Expand CodeModel::FunctionType accordingly. Change-Id: I2759f45e4c60f36d4583b1c475c4c2df1e00ace6 Reviewed-by: Christian Tismer <tismer@stackless.com>
* move everying into sources/shiboken2 (5.9 edition)Oswald Buddenhagen2017-05-221-0/+770
in preparation for a subtree merge. this should not be necessary to do in a separate commit, but git is a tad stupid about following history correctly without it.