summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/moc/tst_moc.cpp
Commit message (Collapse)AuthorAgeFilesLines
* moc: Treat number + characters as Identifier, not NumberFabian Kosmale8 days1-0/+30
| | | | | | | | | | | | | | | | | While <DIGIT>+<Character> is not a valid identifier by itself in the C++ language, it might become one when using it with the token pasting operator. This risks confusing some number literals with suffix as Identifiers, but those are currently not supported anyway, so this shouldn't break anything that is currently working. Fixes: QTBUG-87219 Fixes: QTBUG-124288 Pick-to: 6.7 Change-Id: If73255cc0e6649bc90c52b1d177aac8ff975ae69 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tst_moc: handle QFile::open failures from non-test functionsGiuseppe D'Angelo11 days1-5/+11
| | | | | | | | | | | Code that sets a test function up should not be fallible, or should be designed to log the failure. In tst_moc this is not the case -- QFile::open is called from within a nested lambda. If that fails, print the error and return an empty optional. Task-number: QTBUG-123623 Change-Id: I8372a6ac7dc22e68d145fa2215fe04ba682ac81b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live QT_TECH_PREVIEW_APIGiuseppe D'Angelo2024-02-201-0/+2
| | | | | | | | | | | | | | | | | | A macro to mark tech preview APIs, in order to make header reviews easier: * newly introduced TP APIs are clearly marked as such; * an API that leaves TP and becomes stable requires to change the header, and not just the documentation (and therefore will again appear in the header review). The idea is to use this macro as if it were a C++ attribute. It can't actually be an attribute, because we want to use it to tag e.g. macro expansions (like Q_PROPERTY). Change-Id: I05c5a91a4fa5bedfbd1c6146d4dc00e1d1d28628 Pick-to: 6.7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Change license for tests filesLucie Gérard2024-02-041-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* moc/QMetaProperty: Remove limitation on non-own-class notify signalsFabian Kosmale2024-01-261-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* tst_moc: fix some -Wunused-* warnings on MinGWMarc Mutz2024-01-101-0/+2
| | | | | | | | | | | Found while inspecting a recent MingWG log file from the CI. Amends da284ef10e0ef80776b9fc9b7bb0e6dc8d71ba63. Pick-to: 6.7 6.6 6.5 6.2 Change-Id: Ife10118710079e60c581314fa857be42452fe810 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_moc: DRY QProcess success verificationMarc Mutz2024-01-101-36/+23
| | | | | | | | | | | | | | | | | | | | While the code that checked that exitCode() == 0 was still consistent between all the callers, when it comes to checking stderr, there were several competing implementations, incl. checking the exitCode and dumping stderr to qDebug(), and using QCOMPARE to QByteArray(), presumably in order to get more detailed output on error. Alas, QCOMPARE's toString() truncates output pretty early, making it impossible to see what's going on on failure. So write a small macro that checks the exitCode _after_ it checked that stderr was empty (printing it in full if it was not), so we consistently get the error message instead of a truncated version, or just "exitCode() != 0" without further details. Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: Ic8547fda3b02c645901962887c6ed7aad01f6ea4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Dissociate QTypeRevision from QVersionNumberMarc Mutz2024-01-101-1/+1
| | | | | | | | | | | | | | | | They have nothing to do with each other, so give QTypeRevision its own header and implementation file instead of piggy-backing on QVersionNumber's. Picking back to current LTS to incur the merge conflict only once, not per (expected) follow-up change. Amends ed080c64ae21d22115d16780a5903d7cc4fd1546. Pick-to: 6.7 6.6 6.5 Change-Id: I2fa5d0e68f95864126bc95e3d8154134eee85553 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Moc: don't stumple over inline namespace in more placesFabian Kosmale2023-11-241-0/+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>
* tst_moc: compile with QT_NO_FOREACHAhmad Samir2023-08-191-5/+4
| | | | | | | | | | | | | specifyMetaTagsFromCmdline(): the loop was iterating over a temporary so it couldn't have modified it; hold it with a const auto variable and use ranged-for. relatedMetaObjectsNameConflict_data(): make the container const and port to ranged-for. Task-number: QTBUG-115839 Change-Id: I6a5afdf0e5a3dd47818da0025fbbeacd05335b39 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Mark all of Qt as free of Q_FOREACH, except where it isn'tMarc Mutz2023-08-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | The density of Q_FOREACH uses in this and some other modules is still extremely high, too high for anyone to tackle in a short amount of time. Even if they're not concentrated in just a few TUs, we need to make progress on a global QT_NO_FOREACH default, so grab the nettle and stick to our strategy: Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from creeping in, and whitelist the affected TUs by #undef'ing QT_NO_FOREACH locally, at the top of each file. For TUs that are part of a larger executable, this requires these files to be compiled separately, so add them to NO_PCH_SOURCES (which implies NO_UNITY_BUILD_SOURCES, too). In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the #undef QT_NO_FOREACH to indicate that these actually test the macro. Task-number: QTBUG-115839 Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QObject: replace _q_reregisterTimers with a lambdaAhmad Samir2023-07-311-14/+16
| | | | | | | | | | | | | | | - Pass the QList by value, no heap allocation and no plain new/delete - A lambda means that there isn't runtime string-based lookup to find the member method in QObjectPrivate The code is only a couple of lines and used in a single place, so might as well move the code from _q_reregisterTimers to the local lambda. Modify tst_moc to account for the numer of methods in QObjectPrivate changing. The test had hardcoded numbers. Change-Id: I07906fc7138b8e601e4695f8d2de1b5fdd88449c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* moc: handle "L" integer suffixFabian Kosmale2023-07-281-0/+5
| | | | | | | | | | | | | | | | This commit adds some initial support for handling the 'L' suffix after numbers. This one is especially important given that the __cplusplus define is using it. Other suffixes will be handled in some later commit, which should also unify the already divergent parse behavior between DIGIT and PP_DIGIT parsing (e.g. when it comes to byte prefixes). Task-number: QTBUG-83160 Task-number: QTBUG-115558 Pick-to: 6.6 6.5 6.2 Change-Id: Ie61eae49c468abfaee80e7e4f7097917a254dc0e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Moc: fix generated code for nested enum class corner caseAhmad Samir2023-06-181-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+28
| | | | | | | | | | | | | | 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: streamline how diagnostic messages are printedAhmad Samir2023-06-051-2/+2
| | | | | | | | | | | | | | | | | | | If we don't have a valid Symbol to get a line number from, or if the symbol.lineNum is -1, print a shorter message containing only the file path. Printing: '/path/to/file:-1:1' isn't useful (and looks wrong). Change error/defaultErrorMsg/warning/note() to delegate to one central method, so that they all behave the same; e.g. previously warning() and note(), guarded against printing "-1" for the line number, whereas error() didn't. This also makes it possible to use error() for reporting other issues (e.g. the size of generator.strings list exceeding INT_MAX, which will happen in a later commit). Pick-to: 6.6 Change-Id: Iddc96e08315fae415be6a84928f845d7bceb4c5f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* MOC: pass the erroneous Symbol as an arg to Parser::error() overloadAhmad Samir2023-05-151-0/+9
| | | | | | | | | | | | | | | | | | | | 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>
* Fix another warning when comparing size_t and qsizetypeVolker Hilsheimer2023-04-181-1/+1
| | | | | | | Amends 07f7ed2badf0cc1972bf6ba15f4c0cde4a773f19. Change-Id: I0644e47e8e9ccd0bcaf074adf99e7481c692b5c1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix warning when comparing size_t with qsizetypeVolker Hilsheimer2023-04-031-1/+1
| | | | | Change-Id: Id8e7ae20aea99f2acb03b665484615bf7f932873 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Record types of enumerationsUlf Hermann2023-03-311-29/+81
| | | | | | | | | | | 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-0/+51
| | | | | | | | | | | | 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>
* Silence warning about deliberately using deprecated APIVolker Hilsheimer2023-03-061-0/+2
| | | | | | | | We test moc's support for [[deprecated]], so don't warn about it. Pick-to: 6.5 Change-Id: Ifda2b81c14cb9802db4bb1d0a1eb17d978ad492a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Allow calling ctors on pre-allocated dataUlf Hermann2023-02-021-0/+37
| | | | | | | | | | | | When calling a ctor this way, an object is created in the memory pointed to by _a[0] using the other arguments for the ctor. This allows separate allocation and initialization of an object through the metaobject system. Fixes: QTBUG-108879 Change-Id: Ifb154373ee42faab281cfb62aa14334980ec6b7d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* 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 container::count() and length() to size() - V5Marc Mutz2022-11-031-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* moc: Add basic support for nested inline namespacesFabian Kosmale2022-09-261-0/+9
| | | | | | | | | | | | | | | 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: Do not fail to compile meta-methods containing non-const ref typesFabian Kosmale2022-09-211-0/+2
| | | | | | | | | | | | | | | | Amends 2d0c31e7d92a3e9df4ce2b9c1d41b94fb12735fc. We were using MetaTypeDecay in qTryMetaTypeInterfaceForType; but that is not used by moc when complete types are enforced. Change qt_metaTypeArray to also use qTryMetaTypeInterfaceForType, so that the code path for "force complete types"[0] and the normal one do not diverge. [0] Most easily enabled by using one of the QML type registration macros. Fixes: QTBUG-106672 Pick-to: 6.4 6.4.0 Change-Id: I9bf14873d1d0c4127a676643f7e8eb77f6e42dc8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* moc: Allow writing properties through bindablesUlf Hermann2022-07-081-21/+58
| | | | | | | | | | | | | 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>
* tst_moc: fix build with GCC 12Thiago Macieira2022-06-241-3/+3
| | | | | | | | | | | | | You can't mismatch the export macros. The QT_MOC_EXPORT_PLUGIN_V2 macro defines these functions as Q_DECL_EXPORT so they can be found by QPluginLoader. We must match the macro here, otherwise GCC 12 complains (tst_moc.cpp is compiled with -fvisibility=hidden): tst_moc.cpp.o: non-canonical reference to canonical protected function `qt_plugin_instance' in moc_plugin_metadata.cpp.o Pick-to: 6.4 Change-Id: Id0fb9ab0089845ee8843fffd16f99893d5730da5 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* moc: fix use of escape sequence of more than one characterThiago Macieira2022-06-221-20/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We had the code to calculate the length, but were improperly using it only for the offset, not the length of the string or its containing array. That resulted in the generated moc output containing: QT_MOC_LITERAL(111, 5), // "\xffz" QT_MOC_LITERAL(114, 5), // "\0012" QT_MOC_LITERAL(117, 23), // "slotWithAReallyLongName" The two strings are described as occupying 5 bytes (length 4 + null terminator), which is incorrect. The offset was correct: 114 - 111 = 3 and 117 - 114 = 3. The new output is: QT_MOC_LITERAL(111, 2), // "\xffz" QT_MOC_LITERAL(114, 2), // "\0012" QT_MOC_LITERAL(117, 23), // "slotWithAReallyLongName" The effect of the array size calculation would only be felt if moc decided it needed a second string array (for strings over 65535 bytes), which would cause the offsets in the second array to be all wrong. There was no such test until now. Drive-by fixing of the newline, indentation, and the stale comment referring to QByteArrayData (Qt 5). Pick-to: 6.2 6.3 6.4 Change-Id: Id0fb9ab0089845ee8843fffd16f9cd01b3e0709a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* moc: Allow reading property values through bindablesUlf Hermann2022-06-221-0/+39
| | | | | | | | | | | | | 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>
* Use SPDX license identifiersLucie Gérard2022-05-161-35/+10
| | | | | | | | | | | | | 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>
* Deprecate {QString, QByteArray}::count()Sona Kurazyan2022-03-121-2/+2
| | | | | | | | | | | | And remove their uses. [ChangeLog][QtCore][Deprecation Notice] Deprecated QString::count() and QByteArray::count() that take no parameters, to avoid confusion with the algorithm overloads of the same name. They can be replaced by size() or length() methods. Change-Id: I6541e3235ab58cf750d89568d66d3b1d9bbd4a04 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* typeNameForCast: use add_pointer instead of string manipulationFabian Kosmale2022-02-181-0/+13
| | | | | | | | | | | | | | 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-2/+24
| | | | | | | | | | | | | | | | | | | | | | 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>
* QPlugin: add qt_plugin_query_metadata_v2() to dynamic pluginsThiago Macieira2021-10-111-11/+2
| | | | | | | | | | They return a pointer to the actual header, skipping the magic string. This is done in preparation for the header located in an ELF note, which won't have the magic. Change-Id: I3eb1bd30e0124f89a052fffd16a8229bec2ad588 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QPlugin: suppress the "QTMETADATA !" magic in static pluginsThiago Macieira2021-10-111-12/+10
| | | | | | | | | | | | | | | | The .qtmetadata section is already suppressed for static plugins, but we carried this unnecessary magic string. For library file formats where we don't have a scanner (Windows COFF PE), a library that linked multiple static plugins could end up with multiple metadata found. We can't suppress the header because the version of moc could be different to the version of Qt, so we need to read the header version too. Right now, the version isn't output by moc (all the logic is in qplugin.h), but this could change again in the future. In any case, 4 extra bytes are not a big deal, so the header stays. Change-Id: I3eb1bd30e0124f89a052fffd16a82088d8303081 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* moc: Support BINDABLE for private propertiesAndrei Golubev2021-08-061-0/+11
| | | | | | | | Hopefully we won't need it but let's have it still at least for consistency Change-Id: I72289e65e5e5613174ad4d98cf8d614f9caae8e6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Test Q_CLASSINFO("foobar", #__VA_ARGS__) in tst_mocAndrei Golubev2021-07-081-0/+18
| | | | | | | | There's a chance that this would be used in some macro, so why not test that this thing works in general (especially since it actually works) Change-Id: Ib9d91fbd17cf16675ae89a99f010dacc5d30967a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Consistent indentation for BINDABLE propertiesAndreas Buhr2021-06-241-3/+6
| | | | | | | | | Triggered by API review in Gerrit patch 355960. Task-number: QTBUG-94407 Pick-to: 6.2 Change-Id: I7cafc1cc9d4b929040b53c6bf92c91d73c3b39f2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove pure-virtual-signals.h include from tst_moc.cppEdward Welbourne2021-06-111-1/+0
| | | | | | | | | | | | | | | | | | The relevant test is conducted by tst_Moc::warnOnVirtualSignal(), added in 2009, <quote> Fix Warning saying that signal cannot be made virtual The test for virtual signal did not work. But we cannot make an error right now or it might break existing code (exemple in task 210879) </quote> but without removing the #include, so we do still get a warning about that when building tst_moc. Pick-to: 6.2 6.1 5.15 Change-Id: I5ea18058f22bbd483d1ff18b0ca7b360f6674ed9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_moc: Use qtpaths instead of qmakeFabian Kosmale2021-05-051-2/+2
| | | | | | | | | We only need to the location of certain paths for the test. For that, qtpaths is sufficient. Change-Id: I5af0d56b548629edc48949150ed8fbd408b617a6 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Moc: parse trailing return typeMårten Nordheim2021-05-041-0/+38
| | | | | | | Pick-to: 5.15 6.1 Fixes: QTBUG-71123 Change-Id: I1c3749f0892fddcc433c9afcb1d6d7c30c97c9d9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Silence a bunch of gcc warnings for the moc testVolker Hilsheimer2021-03-291-1/+5
| | | | | | | | We deliberately expose moc to warning-worthy C++, but we don't want the compiler warnings coming from those. Change-Id: I09c36d7c8bfbb88f7bde61fa7bcc52a5adde81da Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move build tools to libexec instead of the bin dirJoerg Bornemann2021-02-231-1/+2
| | | | | | | | | | | | | | [ChangeLog][Build System] Tools that are called by the build system and are unlikely to be called by the user are now installed to the libexec directory. This is a step towards easier co-installability of different Qt versions. Pick-to: 6.1 Task-number: QTBUG-88791 Change-Id: Id19575b5ba27795f7715e4ea6a09391b26dd4942 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Replace QtTest headers with QTestDavid Skoland2020-12-221-1/+2
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* moc: output errors and warnings in a way that matches compilersVolker Hilsheimer2020-11-091-50/+50
| | | | | | | | | | | | | | | | | | gcc, clang, and MSVC all use lowercase "warning:", "error:" and "note:". Follow that standard. Also, include a column number; just print 1, as the Symbol doesn't give us a column number, and searching backwards for a newline seems overkill. This fixes IDE integrations that parse compiler output using regular expressions. The test checks for moc output, but most tests were so far only running on Linux systems. Expand this to Unix for most tests, which then includes macOS. Change-Id: I0a6151cc0dc50e52ca72ff8048a45213aebdb3a8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix compile time type normalization codeLars Knoll2020-10-141-1/+3
| | | | | | | | | | | | | | | | | | | | | Use a simpler constexpr to generate type name on gcc This works around an ICE on gcc in release mode when compiling with PCH enabled. As the type we're getting from Q_FUNC_INFO is already in a somewhat normalized form, this requires significanlty less processing and esp. not a recursive constexpr method which I suspect triggers the ICE. Fix integer type conversions to also properly normalize long long values (to q(u)longlong. Make sure the mapping also works on MSVC, where long long types get mapped to __int64. Also, normalize unsigned short and unsigned char to ushort and uchar, respectively, to follow the convention set by uint and ulong. Add some test cases to verify the mappings. Change-Id: I3dec5764450bf22ab6f066597803c3f46c2cd5ac Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-071-10/+10
| | | | | | | | | This time based on grepping to also include documentation, tests and examples previously missed by the automatic tool. Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix deprecation warnings in testsVolker Hilsheimer2020-09-171-3/+3
| | | | | | | | Adjust to changes to QIcon::pixmap, QMetaType::type, and QAbstractItemView::itemDelegate. Change-Id: I9eb0331ef899131afc86c33f27feeee76331ffc8 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>