summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/moc.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove extra semi-colonsTasuku Suzuki2024-02-061-2/+2
| | | | | Change-Id: I92fddb36cd136fd1bd627955f15d0559b9942d7e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* moc: store the FQN in JSON superClass objectsMarc Mutz2024-01-261-2/+13
| | | | | | | | | | | Tooling can then use this information to find the correct base class, even absent C++ scoping information. Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-101141 Change-Id: I5350da8d2d9aaf5ec86027357131ebac1eb50372 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* moc/QMetaProperty: Remove limitation on non-own-class notify signalsFabian Kosmale2024-01-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The moc generated code does a sanity check that NOTIFY signals actually exist in the parent class when they cannot be found in the class moc currently runs on. The logic there was however too simplistic, and couldn't deal with signals taking a parameter. Fix this, and take the opportunity to use a proper static_assert instead of generating a "normal" compile error. We do not do any checks for the presence of QPrivateSignal, as the whole point of QPrivateSignal is that it should be private (and not e.g. protected). Moreover, we adjust QMetaProperty::notifySignalIndex to take single-argument notify methods into consideration as well when encontering an unresolved notify index. Fixes: QTBUG-115989 Pick-to: 6.7 Change-Id: I8a056a15777f3132691e207b4b9ab6c2c9b2126d Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: port from pair<> to a struct SuperClassMarc Mutz2023-12-131-8/+6
| | | | | | | | | | | | ... with properly-named members. This is in preparation of adding a new member in order to fix QTBUG-101141 (namespaced base classes). Pick-to: 6.7 6.6 6.5 Task-number: QTBUG-101141 Change-Id: I2309e425ac94ad275b54a898fd33a2891e5d1453 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Moc: don't stumple over inline namespace in more placesFabian Kosmale2023-11-241-1/+3
| | | | | | | | | | | | | Ignore the 'inline' in case of nested namespace with another nested inline namespace. Amends 5222df2be7d10bf44dfc2971774eadcb526b7a13 Fixes: QTBUG-117765 Pick-to: 6.6 6.5 Change-Id: I87f2649606f63c818f225f8cc5ec914920763c5f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Drop support for function declaration without type specifierFabian Kosmale2023-08-261-28/+23
| | | | | | | | | | | Neither C++ nor modern C allow omitting the type (which used to be equivalent to an "int" return type). moc should not try to parse functions in C code, as they cannot be meta-methods. So there is no point in supporting it. Change-Id: I2b3a492988f29e8139311db64be110581cc1a4de Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: use QList::removeIfAhmad Samir2023-06-221-7/+7
| | | | | | | | | | | Yes, the code now uses two loops, but it's slightly better than erasing-during-iteration; the alternative is using e.g. a while loop and advancing an iterator manually with operator++() (in two separate locations, since there would be a `continue` statement) or with the return value of QList::erase (in one location). Change-Id: I119d0e61bc06396f2158ecf9f4ae84a76d9bce7b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Moc: simplify showing a warningAhmad Samir2023-06-221-5/+2
| | | | | | | | | Instead of changing the "index" member then restoring it, add a symbolAt() method to get the Symbol in question, and pass it to new warning() overload. Change-Id: Ie84a6cf4d837f4ed694f617100e9556c2fc2eea3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Moc: fix narrowing conversion warnings with range-for loopsAhmad Samir2023-06-201-2/+2
| | | | | | Pick-to: 6.6 6.5 Change-Id: I6dee1a6ae82c33bd6523734ee32ab4c83835f9d8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Moc: port to qsizetypeAhmad Samir2023-06-201-6/+6
| | | | | | | Pick-to: 6.6 6.5 Change-Id: Ibacc9b4bd6c26b890a09f689c730286c2aa0894c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: fix generated code for nested enum class corner caseAhmad Samir2023-06-181-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes an issue with generated code where the name of an enclosing namespace is identical to an enum class type, when Q_ENUM_NS is used. Consider: namespace a { Q_NAMESPACE namespace b { enum class b { Key, Key2 }; Q_ENUM_NS(b); } } moc generated code such as: Q_CONSTINIT const QMetaObject a::b::staticMetaObject = { { ... qt_incomplete_metaTypeArray<qt_meta_stringdata_CLASSaSCOPEbENDCLASS_t, // enum 'TestEnum' QtPrivate::TypeAndForceComplete<b::b, std::true_type>, // Q_OBJECT / Q_GADGET QtPrivate::TypeAndForceComplete<void, std::true_type> >, nullptr } }; which confused the compiler: error: ‘b’ is not a member of ‘a::b::b 83 | QtPrivate::TypeAndForceComplete<b::b, std::true_type>, Fixes: QTBUG-112996 Pick-to: 6.6 Change-Id: I37aee83c32efe96cc9d6c2bd0bdb9ba80bb7b8a7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Handle attributes after meta-method tagFabian Kosmale2023-06-161-4/+17
| | | | | | | | | | | | | | We so far only handled them if they came at the very start of the method declaration. This patch ensures that we also handle them after the meta-method tag (but before the actual type). Unifying parseFunction and parseMaybeFunction to avoid the need to munally keep them in sync is left for another day. Fixes: QTBUG-111330 Pick-to: 6.6 6.5 6.5.2 6.2 Change-Id: Ic94edb69f04b9150aea2c8e6d004a8b9e5cf12ec Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: check sizes of specific member QLists are within INT_MAX rangeAhmad Samir2023-06-061-3/+46
| | | | | | | | | | | | | | Parts of the public API, e.g. QMetaMethod::methodIndex and similar functions return int, and other parts of the code expect int values, at least for Qt6 this can't be changed, so use qsizetype internally and assert the values fit in an int. As pointed out in code review, not many people will build moc in debug mode, so asserts aren't that useful here. Instead print error messages and exit, like is already done in other parts of the code. Change-Id: Id305165caa996c899f30770a757098fe2f9a96f6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: pass a pointer to the parser to the GeneratorAhmad Samir2023-06-061-1/+2
| | | | | | | | | This way the Generator can use e.g. Parser::error() to print error messages (which will happen in a later commit). Change-Id: Id710d7b604a82ce6bb61999addad8c95c53e3226 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: assert size of registered strings list is within INT_MAX rangeAhmad Samir2023-06-061-0/+6
| | | | | | | | | | | | | | Assert generator.strings.size() < INT_MAX after all strings have been registered. Parts of the public API, e.g. QMetaMethod::methodIndex and similar functions return int, and other parts of the code expect int values, at least for Qt6 this can't be changed, so use qsizetype internally and assert the values fit in an int. Change-Id: Ib226e9c19a578bbeaeb9bb767d756a9569fe57b3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: remove STRINGDATA fallback codeAhmad Samir2023-06-051-10/+1
| | | | | | | | | | | | | | | | If QT_MOC_HAS_STRINGDATA isn't defined, just put an '#error' directive in the generated code. Since the proposal of doing ±4 versions of tool compatibility hasn't been adopted, just remove the fallback string code. Requested by Thiago in code review. Drive-by changes: - Use "STRINGDATA" in comments too - Remove a now unused static helper Change-Id: I6dbdf427b7219b8b32076a9e0a41799c0a476ff9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: port to qsizetypeAhmad Samir2023-05-281-1/+1
| | | | | | | | Simple s/int/qsizetype/. Fixes some narrowing conversion warnings. Pick-to: 6.5 Change-Id: Ied82e861298fa9763089cadc7eae6e536f1bb9ca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: only call checkSuperClasses() if the class inherits anotherAhmad Samir2023-05-281-4/+6
| | | | | | | | I.e. if def.superclassList is empty, calling checkSuperClasses() is no-op. Spotted by Fabian in code review. Change-Id: I499baf1d2cf6dd08a26394221a48af991ccea4ad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Moc: fix narrowing conversion warnings with iterators/algorithmsAhmad Samir2023-05-281-17/+22
| | | | | | | | Drive-by change: check a QList isn't empty before using first() Pick-to: 6.5 Change-Id: I24171d17244ae96ad5779d721c65d33e5489f5f3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Moc: fix some narrowing conversion warnings by using reverse iteratorsAhmad Samir2023-05-181-11/+15
| | | | | | | | And de-duplicating some code. Pick-to: 6.5 Change-Id: Ibfb581cd296a120ff8328ae672020cc36ca5d328 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Moc: fix some narrowing conversion warnings by using range operationsAhmad Samir2023-05-181-8/+8
| | | | | | | | | | | | I.e. range-for and in one case QList::append(iterator, iterator). Drive-by changes: - Check a QByteArray isn't empty before using at() - Shorten a long line, QString::fromLocal8Bit() works with QByteArray Pick-to: 6.5 Change-Id: I7e54ce39f65ccb1fe5e60693ac98e239b9f0d794 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* MOC: pass the erroneous Symbol as an arg to Parser::error() overloadAhmad Samir2023-05-151-13/+14
| | | | | | | | | | | | | | | | | | | | We already know the Symbol while parsing, passing a reference to it to error() makes it simpler to construct the error message. This fixes an issue where reporting an error about "NONSENSE" in e.g.: Q_PROPERTY(Foo* foo NONSENSE foo) would be off-by-one and the error message would say: path/to/file.h:11:1: error: Parse error at "foo" instead of 'at "NONSENSE"', which is where the parser actually found an unexpected attribute. Fixes: QTBUG-36367 Pick-to: 6.5 Change-Id: Ief70e544af41f7575fbeea9b936fa8197c3ef43d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Record types of enumerationsUlf Hermann2023-03-311-1/+3
| | | | | | | | | | | This will be helpful in a number of places, in particular in order to support enums of different sizes in QML. We record the type as string in the JSON output and as QMetaTypeInterface in the generated C++. Task-number: QTBUG-112180 Change-Id: I943fac67f8b25b013d3860301416cdd293c0c69e Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Allow anonymous propertiesUlf Hermann2023-03-161-9/+17
| | | | | | | | | | | | This is private for now. It's very handy to have anonymous properties for the QML model/delegate adaptors. There are models with only "singular" model data that doesn't have any sub-properties. Such model data should be available from the model object via an empty string as role. This way we can get rid of a lot of special casing. Task-number: QTBUG-104752 Change-Id: I229e355a7cab064ee1c9f89557bc0244a5d0c90a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: don't include any std headers before user class headersStefan Sichler2022-11-301-1/+5
| | | | | | | | | don't `#include <memory>` before including the header of the user's class(es), because the user may want to configure certain aspects of stl/crt before including any standard headers. Change-Id: I58f13d3604358221e3375a309eb747efecf3f990 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* moc: Output the "cloned" flag for methodsUlf Hermann2022-11-271-0/+3
| | | | | | | | | We will need it in QML to determine which signal out of a number of "overloads" to generate handlers for. Task-number: QTBUG-108762 Change-Id: Ib73eeb59dbf037bd03faf0d841860d9ebc9e7032 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-6/+6
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* moc: Add basic support for nested inline namespacesFabian Kosmale2022-09-261-0/+6
| | | | | | | | | | | | | | | This improves moc's support for nested inline namespaces, so that code containing them will not break compilation. For simplicity, we allow nested inline namespaces even in C++17 mode (the actual C++ compiler will reject the code anyway, and probably with a better error message than moc could output). moc still has no real awareness how inline namespaces work, but that is a preexisting issue. Pick-to: 6.4 6.2 Fixes: QTBUG-106920 Change-Id: I7b415a99133575f101bc81d01d4670a5f752917f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* moc: move some of the helpers into a header dedicated to itThiago Macieira2022-08-041-2/+10
| | | | | Change-Id: Id0fb9ab0089845ee8843fffd16f9d080029f2f7f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* moc: handle attributes in class declarationsFabian Kosmale2022-08-031-0/+3
| | | | | | | | | | | | We already had code to handle attributes on funtcions, but we didn't handle them correctly for classes so far. Fix this by simply skipping over the attribute. Fixes: QTBUG-105310 Pick-to: 5.15 6.2 6.3 6.4 Change-Id: Ic4149f940e74820de4f2fa9540d9dc5b4e626a3a Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* moc: Allow writing properties through bindablesUlf Hermann2022-07-081-1/+7
| | | | | | | | | | | | | BINDABLE should generally behave the same as MEMBER if "WRITE default", except where it cannot. In particular we cannot know if any NOTIFY signal should be sent from the synthetic WRITE accessor. [ChangeLog][QtCore] moc will now synthesize WRITE accessors for properties with BINDABLE if you specify "WRITE default". Task-number: QTBUG-97249 Change-Id: I883c40ba0dda7989c840971860addaeaa75a8c83 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Cleanup handling of default arguments in functionsAndrei Golubev2022-06-271-35/+18
| | | | | Change-Id: I0a381525b92ce5f0b51296a02d9ab98c7a204efc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* moc: Strip parentheses from RESET methods in JSON outputUlf Hermann2022-06-271-1/+1
| | | | | | | | | READ, WRITE, NOTIFY etc all come without parentheses. What we actually want to check in the generator is whether the reset method is empty. Task-number: QTBUG-104508 Change-Id: If8c70c7491b25e3c4d9a39dc2c0add0212e64dea Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* moc: add Q_CONSTINIT to the static const variables we emitThiago Macieira2022-06-221-0/+6
| | | | | | | | | | | The macro was added to Qt 6.4, so we define it in each moc output to empty if it wasn't previously defined. Thus, moc retains compatibility with older Qt versions. Pick-to: 6.4 Change-Id: Id0fb9ab0089845ee8843fffd16f9c1539fa0368f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* moc: Allow reading property values through bindablesUlf Hermann2022-06-221-0/+10
| | | | | | | | | | | | | The behavior is similar to MEMBER: If the READ accessor is "default", synthesize it using the bindable. [ChangeLog][QtCore] You can now specify "READ default" in a Q_PROPERTY if you also specify a BINDABLE. moc will synthesize a READ accessor in that case. Task-number: QTBUG-97249 Change-Id: I4a275adabaed12df95dac505095f847c4be65dfe Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: remove unnecessary emission of "#include <qbytearray.h>"Thiago Macieira2022-06-211-1/+0
| | | | | | | | | | | | | | | | We don't need QByteArrayData any more (since 6.0). [ChangeLog][Potentially Source-Incompatible Changes] moc no longer emits an #include for QByteArray in the output file. None of the content that moc generates needed that header, so this should not cause changes for most people. However, codebases that #include'd the moc output (something that is recommended) could be depending on this indirect include. Pick-to: 6.4 Change-Id: Id0fb9ab0089845ee8843fffd16f9cf13dc8d61b5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Disable useless-cast warning for moc generated codeMate Barany2022-06-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | The useless-cast gcc warning is disabled in the files generated by the moc. A typical warning is like using_t = void(Counter::*)(int ); if (*reinterpret_cast<_t*>(_a[1]) == static_cast<_t>(&Counter::valueChanged)) { *result = 0; return; } Removing the static cast results in a compilation error "address of overloaded function with no contextual type-of information" in moc_myobject.cpp files. Checking whether we have an overload set or a single function might be too much effort for too little benefit and may not worth it. Fixes: QTBUG-71938 Change-Id: I6f67e163a3493b51fb95f54218ce6bf9a302f824 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-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: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Tools: replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-05-031-3/+3
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ie136f600f823019c29461561d4e30be66a66e87b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Tools: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-05-031-44/+46
| | | | | | | | | As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Task-number: QTBUG-98434 Change-Id: I6d4712a71b5ebf3f379f1f98ea476557bce963ef Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* typeNameForCast: use add_pointer instead of string manipulationFabian Kosmale2022-02-181-1/+1
| | | | | | | | | | | | | | Relying on string manipulation leads to -Wredundant-parens warnings in the best case, and to non-compiling code (when using typedefs) in the worst case. We can avoid both issues by simply generating code that uses add_pointer, which takes care of reference types (even typedef'd ones), and creates no warnings about parens (as we don't write any anymore). Fixes: QTBUG-100915 Pick-to: 6.3 6.2 Change-Id: Ic5b1cbfda20d920d11f51beeb62e9479261d5f00 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Long live Q_GADGET_EXPORT!Marc Mutz2021-11-271-1/+13
| | | | | | | | | | | | | | | | | | | | | | Like Q_NAMESPACE_EXPORT for Q_NAMESPACE, this variant of Q_GADGET allows passing an export macro. This is useful to avoid exporting the whole class just to get the staticMetaObject hidden therein exported. Before anyone asks: No, we don't need Q_OBJECT_EXPORT, because QObject subclasses, being polymorphic, always need to have a class-level export macro (to export their vtable), but while that technique also works for value classes (the Q_GADGET audience), it is not desirable for them, because it makes inline functions exported in Windows debug builds, which is not what we want, because it needlessly restricts what you can to with the inline functions (e.g. remove). [ChangeLog][QtCore] Added the Q_GADGET_EXPORT macro, which is like Q_GADGET, but allows passing an export macro (like Q_NAMESPACE_EXPORT for Q_NAMESPACE). Fixes: QTBUG-55458 Change-Id: I546297de1e8aa45d83381991bcd3fbca61e1eef0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tools: Fix typos in source code commentsJonas Kvinge2021-10-121-2/+2
| | | | | Change-Id: I9666104a320f66b22c5144375ce7440bb59737e6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Handle even more include in enum casesFabian Kosmale2021-08-061-2/+1
| | | | | | | | | | | | | | The solution in d3ed7dac8aa2f4ede0c409254b9dd44842086be0 was needlessly complicated, and broke a valid use case. The issue of no identifier being available to parse after the include has been processed can instead be solved by moving the test for the closing brace after the include processing. Fixes: QTBUG-94790 Pick-to: 6.2 6.1 5.15 Change-Id: Ieec4b89e1d117637f11479e8bddc4060f93da43d Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QDuplicateTracker: accept the number of elements to reserve as a ctor argumentMarc Mutz2021-07-141-1/+1
| | | | | | | | | | | | This prevents us from first reserve()ing Prealloc elements, and then possibly reserve()ing a larger number, which leaves the first bucket list's memory unused. Consequently, deprecate reserve(). Change-Id: Ifc0a5a021097f4589557e7b5e45d9d0892797ade Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* moc: Add relative property index to JSON output of PropertyDefAndrei Golubev2021-06-021-4/+5
| | | | | | | | Needed for QML compiler to know property index of C++ type at compile time without going through QMetaObject::indexOfProperty Change-Id: I404e71d6071d36812661df17d12b879a8dcbd146 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Moc: parse trailing return typeMårten Nordheim2021-05-041-9/+21
| | | | | | | Pick-to: 5.15 6.1 Fixes: QTBUG-71123 Change-Id: I1c3749f0892fddcc433c9afcb1d6d7c30c97c9d9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Adjust code format, add space after 'if'Zhang Sheng2020-11-161-4/+4
| | | | | | Change-Id: Ice081c891ff7f4b766f49dd4bd5cf18c30237acf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* moc: Handle include in enum, take 2Fabian Kosmale2020-11-031-3/+19
| | | | | | | | | | | | The existing logic broke down when we reentered the enumerator parsing loop, and encountered a INCLUDE_MOC_END token in the first handleInclude call. Fix this by restarting the loop in that case. Amends d8a2456fbf18f60e2d1950585d93aa530df077bf. Fixes: QTBUG-88125 Pick-to: 5.15 Change-Id: I87acaa986a81de53730eddc40bc7d48c15328aba Reviewed-by: Lars Knoll <lars.knoll@qt.io>