summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qmetatype
Commit message (Collapse)AuthorAgeFilesLines
* Tests: check the output of QFile::openGiuseppe D'Angelo2024-03-271-1/+1
| | | | | | | | | | Wrap the call in QVERIFY. tst_QTextStream::read0d0d0a was also faulty as it *never* opened the file because of a broken path. Fix it with QFINDTESTDATA. Change-Id: I61a8f83beddf098d37fda13cb3bfb4aaa4913fc5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change license for tests filesLucie Gérard2024-02-049-9/+9
| | | | | | | | | | | | 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>
* QMetaType: fix typenameHelper() for types in the QtPrivate namespaceThiago Macieira2023-12-082-0/+16
| | | | | | | | | | | | | | | | | | GCC at some point decided that it wouldn't include the full namespace expansion in __PRETTY_FUNCTION__ for any type that is in the same namespace as the template function being expanded (that is, the QtPrivate) namespace. I don't know how long this behavior has been in place, but it can be seen with GCC 13, where the expansion of that macro inside QtPrivate::typenameHelper<QtPrivate::ModelIndex>() is: constexpr auto QtPrivate::typenameHelper() [with T = ModelIndex] This can be easily worked around by using a different namespace. Fixes: QTBUG-119650 Pick-to: 6.6 6.5 6.2 Change-Id: Ica7a43f6147b49c187ccfffd179df309e43a70cb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: fix recursive detection of std::optional operatorsThiago Macieira2023-07-311-0/+20
| | | | | | | | | | | | | | Commit ca54b741d6edda24773137aacee229db31dd3585 used the internal has_operator_equal (and commit 01d94760d8d34e51e1442682fc151747943c7e25 copied that for has_operator_less_than) instead of using the recursive expander that was being used here. That assumed that the contained type in std::optional would always be the last final check, which is an incorrect assumption. Fixes: QTBUG-115646 Pick-to: 6.6 6.5 Change-Id: Ifbf974a4d10745b099b1fffd177702934bec27ff Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Make corelib tests standalone projectsAlexandru Croitor2023-07-051-0/+6
| | | | | | | | | | | | | | | | | | Add the boilerplate standalone test prelude to each test, so that they can be opened with an IDE without the qt-cmake-standalone-test script, but directly with qt-cmake or cmake. Boilerplate was added using the following scripts: https://git.qt.io/alcroito/cmake_refactor Manual adjustments were made where the code was inserted in the wrong location. Task-number: QTBUG-93020 Change-Id: I28b6d3815c5f43d2c33ea65764f6f3f8f129eaf3 Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaType: Provide underlyingType for enumsFabian Kosmale2023-03-282-0/+56
| | | | | | | | | | | | | | | | | | | | | | Currently, Qt assumes that enums always have int as their underlying type (both in QMetaEnum::keyToValue and in the QML engine). This change makes it possible to to retrieve the underlying type from an enum's metaype - or rather, a metatype of an integral type with the same size and signedness. The use cases aobve don't really rely on the exact same type. In most cases, we wouldn't even need the signedness, however that is already available anyway, and it will come in handy once QML supports bigint, and we need to decide whether we should return While it would be possible for individual users of this function to manually query the size and signedness, having a function returning a metatype offers additional convenience - especially in QML, where the conversion APIs generally operate on metatypes. Task-number: QTBUG-27451 Task-number: QTBUG-84055 Task-number: QTBUG-112180 Change-Id: Icf733b42df0ea64017d69f4d94cb7c855d9e3201 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tests: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-171-2/+0
| | | | | | | Pick-to: 6.5 Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QMetaType: fix value-initialization in a corner caseGiuseppe D'Angelo2022-12-302-1/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a type is trivially default constructible, QMetaType (and QVariant) think that it can be built and value-initialized by zero-filling a region of storage and then "blessing" that storage as an actual instance of the type to build. This is done as an optimization. This doesn't work for all trivially constructible types. For instance, on the Itanium C++ ABI, pointers to data members are actually value-initialized (= zero-initialized, = initialized to null) with the value -1: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#data-member-pointers This means that a type like struct A { int A::*ptr; }; is trivially constructible, but its value initialization is not equivalent to zero-filling its storage. Since C++ does not offer a type trait we can use for the detection that we want to do here, and since we have also decided that Q_PRIMITIVE_TYPE isn't that trait (it just means trivially copyable / destructible), I'm rolling out a custom type trait for the purpose. This type trait is private for the moment being (there's no Q_DECLARE_TYPEINFO for it), and limited to the subset of scalar types that we know can be value-initialized by memset(0) into their storage (basically, all of them, except for pointers to data members). The fix tries to keep the pre-existing semantics of `QMetaType::NeedsConstruction`. Before, the flag was set for types which were not trivially default constructible. That included types that aren't default constructible, or types that cannot do so trivially. I've left that meaning unchanged, and simply amended the "trivial" part with the custom trait. A fix there (to clarify the semantics) can be done as a separate change. Change-Id: Id8da6acb913df83fc87e5d37e2349a4628e72e91 Pick-to: 6.5 Fixes: QTBUG-109594 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qfloat16: make it a built-in metatypeThiago Macieira2022-11-281-0/+3
| | | | | | | | | | | I've reserved the IDs for int128, uint128, bfloat16, and float128, because the mask in qvariant.cpp's qIsNumericType() requires primitives to be less than 64 to operate properly. Added a QMetaType/QDataStream test to confirm it is indeed built-in. Change-Id: I3d74c753055744deb8acfffd17247f7f57bada02 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QMetaType: Support custom unary converters with optional<To> return typeArno Rehn2022-09-271-14/+53
| | | | | | | | | | | | | | | To indicate success of a conversion, the public API has previously only supported registering member functions of the form To (From::*)(bool *). When adding custom converters for types that cannot be modified, this is usually not a possibility. As an alternative, this patch adds support for std::optional in the UnaryFunction overload of QMetaType::registerConverter. If the returned optional has no value, the conversion is considered failed. Task-number: QTBUG-92902 Change-Id: Ibac52d2cb9b5a2457081b4bebb0def1f03e3c55d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compile guard tests in corelib/kernel that need threading supportMikolaj Boc2022-09-112-0/+4
| | | | | | | | | Some tests in corelib/kernel need threading support, but they are not guarded against compilation if Qt is built without threading. Such tests have been disabled in this case. Change-Id: I2f5dc9582f2a59b6af2a9e56638b045dca06193d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* tst_qmetatype: port away from deprecated callsIvan Solovev2022-08-304-156/+304
| | | | | | | | | | | | | | | | | | | | | | | | The most common changes are: * Replace QMetaType::type("name") with QMetaType::fromName("name").id() or QMetaType::fromType<Type>().id() * QMetaType::typeName(int) -> QMetaType(int).name() * QMetaType::typeFlags(int) -> QMetaType(int).flags() * QMetaType::metaObjectForType(int) -> QMetaType(int).metaObject() * The static QMetaType::{load,save} methods are replaced with non-static versions * The static QMetaType::{create,destroy,construct, destruct} methods are guarded by QT_DEPRECATED_SINCE calls. The tests are also extended with non-static calls where they were missing. Fixed potential memory-leaks in these tests. Add separate unit-tests for deprecated APIs and guard them with QT_DEPRECATED_SINCE As a drive-by: use nullptr instead of 0 in some places Task-number: QTBUG-104858 Change-Id: I4b0cdd29bc197c186b835002372240aae3098c33 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-231-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Rename QT_DISABLE_DEPRECATED_BEFORE -> QT_DISABLE_DEPRECATED_UP_TOIvan Solovev2022-08-191-1/+1
| | | | | | | | | | | | | | The new name describes the behavior in a better way. [ChangeLog][Build System] The QT_DISABLE_DEPRECATED_BEFORE macro is renamed to QT_DISABLE_DEPRECATED_UP_TO. The old name is deprecated, but is still recognized if it is defined during configuration and the new name is not defined. Task-number: QTBUG-104944 Change-Id: Ifc34323e0bbd9e3dc2f86c3e80d4d0940ebccbb8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QMetaType: don't use global relocations to the lambdas and structuresThiago Macieira2022-08-121-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | The way the Qt 6.0 QMetaTypeInterface was designed, using a static inline variable in a template, would normally require the linker and dynamic linker to merge all copies and choose a single copy as the official one. But because of hidden visibility and of Windows DLLs, QMetaType already copes with multiple copies NOT getting merged. So we may as well ask the linkers not to bother and use simpler, local relocations to find those symbols. They are all supposed to still be equivalent and it's an ODR violation if they're not. The Apple ld64 linker complains if you use this type of global relocation: ld: warning: direct access in function [...] to global weak symbol 'QtPrivate::QMetaTypeInterfaceWrapper<int>::metaType' Fixes: QTBUG-93471 Pick-to: 6.3 6.4 Change-Id: Id0fb9ab0089845ee8843fffd16f98a10aa719434 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: add a test to confirm that types are equal across librariesThiago Macieira2022-08-127-5/+193
| | | | | | | | Because of the template shenanigans. This is just to make sure. Pick-to: 6.4 Change-Id: Id0fb9ab0089845ee8843fffd16f989e7d555894f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-031-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* tst_QMetaType: fix warning that buffer may be unusedThiago Macieira2022-07-311-2/+2
| | | | | | | | | | | | | We pass a pointer to uninitialized memory to QMetaType::create(). There's no harm because we're using the invalid QMetaType, but GCC is actually right to complain for any other type. qtestcase.h:54:25: warning: ‘buf’ may be used uninitialized [-Wmaybe-uninitialized] qmetatype.h:454:11: note: by argument 2 of type ‘const void*’ to ‘void* QMetaType::create(const void*) const’ declared here Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd1703eb7967acf0d7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-281-1/+1
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QMetaType: don't record trivial construction function pointersThiago Macieira2022-07-272-20/+106
| | | | | | | | | | | | We can implement the trivial {default,copy,move} construction outselves inside qmetatype.cpp and qvariant.cpp, simplifying the QMetaType interface object, removing up to three relocations per QMTI. This adds the testing for QMetaType::isXxxConstructible and isDestructible that couldn't be added before. Change-Id: Ic44396b31ba04712aab3fffd16ff0a28f541d507 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: add registerType() and qRegisterMetaType(QMetaType)Thiago Macieira2022-07-261-0/+24
| | | | | | | | | | | | | | | | | | | | | | | This also rewrites QMetaType::id() on top of the helper, with the benefit of calling a member static function, so QMetaType doesn't need to be spilled onto the stack. In some upcoming changes I need to ensure that QMetaTypes are registered so they can be found by name and I'd like to have a dedicated function name for that, instead of calling .id(). Since I needed to add docs for the new function, I've updated for the old one too. [ChangeLog][QMetaType] Added QMetaType::registerType() and an overload of qRegisterMetaType() taking QMetaType (the two functions do the same thing). These two functions ensure a given QMetaType is registered with the Qt global registry, so they can be found by name later. Using qRegisterMetaType<T>() also accomplishes the same thing, but is slightly better for completely generic code because it will avoid emitting the registration for built-in types. Change-Id: I3859764fed084846bcb0fffd170351d606034c22 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: fix isRegistered()Thiago Macieira2022-07-262-0/+10
| | | | | | | | It's not registered until an ID is assigned. Pick-to: 6.4 Change-Id: I3859764fed084846bcb0fffd17034f5b369c5b4d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaType: suppress most warningsThiago Macieira2022-07-261-1/+16
| | | | | | | | It's not warning-free, but it's much better. Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd170323c9ed12dd23 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaType: merge flags and flagsStaticlessThiago Macieira2022-07-262-52/+42
| | | | | | | | | And rewrite them with templates. QMetaType::typeFlags() simply calls flags() anyway. Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd170323f9d8c80466 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Specialize MetaObjectForType for non-pointer QObject-derived typesMikolaj Boc2022-07-121-0/+1
| | | | | | | | | | | | | | | | | | QMetaTypeInterfaceWrapper tries to find the metaObjectFunction using the MetaObjectForType template. Using SFINAE, for a QObject, it should resolve to a suitable specialization. Such a specialization doesn't yet exist. It had to be created. The following path returns nullptr for registered meta types: auto metatype = QMetaType(typeId); requestedTestType.metaObject() -> returns nullptr since a bad template argument is fed to MetaObjectForType<T> in QMetaTypeInterfaceWrapper<IneritingFromQObject>::metaType's static initializer. Change-Id: I8b31c51e12cb19c333e00480b0177354b910ce1e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-165-135/+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>
* QMetaType: Fix normalization on MSVC if name contains enumFabian Kosmale2022-05-121-0/+6
| | | | | | | | | | | | | | | During type normalization, we remove the struct, class and enum keywords (see the skipStructClassOrEnum function). However, we only want to do that for actual keywords, not for a name that happens to start with e.g. "enum", as in "enumerationNameSpacce". Adjust the MSVC check to still require no identifier character after the keyword, while still allowing for some remaining characters. Fixes: QTBUG-97813 Pick-to: 6.3 6.2 Change-Id: I82b873d02ff454cce4b75f2814a52a66f2268208 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up includes involving tst_qmetatype_common.hEdward Welbourne2022-04-262-4/+4
| | | | | | | | | | | The functions it defines depend on many many types in QtCore for which it did not have a #include; both files that included it thus had to pull in QtCore to compile. Put that #include where it belongs and clean out many specific QtCore includes that it makes redundant. Change-Id: Ie9d9ec325d4879d771cb14baecb06fecbdaf62c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Cleanup tests that add test data to resources explicitlyAlexey Edelev2022-02-111-17/+0
| | | | | | | | | | | | Remove Integrity and Android specific code that explicitly adds test data to the resource files. qt_internal_add_test functions implicitly adds test data to resources for Android and Integrity platforms by default. Change-Id: Ia1d58755b47442e1953462e38606f70fec262368 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_QMetaType: remove call to pthread_yield()Thiago Macieira2022-01-191-3/+0
| | | | | | | | | It was Linux-only and now even Linux is complaining: tst_qmetatype.cpp:421:26: warning: ‘int pthread_yield()’ is deprecated: pthread_yield is deprecated, use sched_yield instead [-Wdeprecated-declarations] Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1eadfa301f16 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QMetaType: remove the IsInitialized checkThiago Macieira2022-01-192-28/+11
| | | | | | | | | All primitive types are initialized and have been since at least commit 33cd680ddbaccf6139e215d851a39e657ae36394 ("New QMetaType representation"). Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1fe22dc5c8f5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qmetatype: add a few more row for QMetaType::UknknownTypeThiago Macieira2022-01-191-0/+23
| | | | | Change-Id: I0e5f6bec596a4a78bd3bfffd16cb215d7f6c6ddb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: add a missing check for null d_ptrThiago Macieira2022-01-182-0/+55
| | | | | | | | | | | | | Bug introduced in 6.0. This is the only unprotected d_ptr I could find. [ChangeLog][QtCore][QMetaType] Fixed a bug that would cause QMetaType::compare() and QVariant::compare() to crash on invalid meta types and variants. Pick-to: 6.2 6.3 Fixes: QTBUG-99960 Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1f7b2d146688 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove unused .qrc filesJoerg Bornemann2022-01-171-5/+0
| | | | | | | | Task-number: QTBUG-94446 Change-Id: I136d8b4ab070a832866aa50b5701fc6bd863df8a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QMetaType: Allow conversion of derived gadget types to their base typesUlf Hermann2022-01-132-2/+30
| | | | | | | | A derived gadget has an is-a relationship with its base type. It should be convertible. In fact, canConvert() already tells us it is. Change-Id: I71a5ac9afd78e88adb23b4d0e757f34077f63207 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_qmetatype: fix memleaksMarc Mutz2021-12-221-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | We didn't delete the new'ed up QMetaTypeInterfaces, causing asan to complain. Fix by storing them in strong references alongside their users in a statically-allocated container. We use shared_ptr to hold them, because QMetaTypeInterface doesn't have a virtual destructor, so deleting objects of the TypeInfo types (plural!) derived from QMetaTypeInterface though a pointer to the base class is UB. The shared_ptr constructor, however, is templated, so it stores the correct call (~TypeInfo()) in its type-erased deleter. We can't use std::make_shared(), because that doesn't support aggregate initialization until C++20, so we manually new up the TypeInfos. 5.15 is not affected. Pick-to: 6.3 6.2 Change-Id: Ic7ec88c34e02a9e0dd3421848c0c0885f4756702 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Fix autotest runtime failures on INTEGRITYTatiana Borisova2021-12-162-0/+19
| | | | | | | | | | | - add test resources to binaries - link Qt::Gui to tst_qpointer for static build case Task-number: QTBUG-99123 Pick-to: 6.2 6.3 Change-Id: I311827b9c641eaf9537091b051c15f9fcbcb9f0c Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qmetatype: remove traces of compiler workarounds againMarc Mutz2021-12-163-13/+0
| | | | | | | | | Now that all platforms can deal with the full tst_QMetaType again, remove the last traces of the workaround. Pick-to: 6.3 Change-Id: I530cab8413f8b68903991b30a1f29b5871877a88 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qmetatype: remove the previous MingW workaroundMarc Mutz2021-12-161-8/+0
| | | | | | | | | | Let's see whether splitting the TUs has made the test amenable to be compiled with MinGW again. Pick-to: 6.3 Change-Id: Icde1bad20943c7648dbb119ca879bce62325bd6c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qmetatype: remove the previous clang-arm workaroundMarc Mutz2021-12-151-5/+0
| | | | | | | | | Let's see whether splitting the TUs has made the test amenable to be compiled on Clang for ARM again. Pick-to: 6.3 Change-Id: I6bf1e31189f5058dc393adefabaf3014dce4bcf2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert "tst_qmetatype: Temporarily disable expensive tests on QNX"Marc Mutz2021-12-151-2/+2
| | | | | | | | | | | | | | This reverts commit 925ad7802470ab9b4fd1cce51548ccc5182eb4cc. Reason for revert: Meanwhile, the QNX VM has been assigned more resources, and the offending test function been split. Re-enable the test on QNX, to get back to previous test coverage. Fixes: QTQAINFRA-4669 Pick-to: 6.3 Change-Id: Ib085fbfa7e0d8445f007d1a9346cee3113620720 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qmetatype: factor the most expensive test into its own TUMarc Mutz2021-12-074-81/+127
| | | | | | | | | | | | | | | | The PRINT_2ARD_TEMPLATE macro expansion alone is responsible for about 50% of the compile time and RAM requirements of tst_qmetatype.cpp. By factoring it into its own TU, we reduce the maximum memory load on my machine from 4.0GiB to 2.5GiB, provided we don't parallelize the build, then we take 0.5GiB more. This is a quick-fix for the QNX build problems currently plaguing the CI. Going forward, we should probably have a better solution, whatever that may be. Task-number: QTQAINFRA-4669 Change-Id: I2732b4c25b369b15cce1c7afe222d041ecb6795a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qmetatype: move an #ifdef to the headerMarc Mutz2021-12-072-8/+8
| | | | | | | | | ... so it can be used by multiple .cpp files. Task-number: QTQAINFRA-4669 Change-Id: I7212b9b08cd3bfa44ee741ee4789d1d0024e4708 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qmetatype: Temporarily disable expensive tests on QNXFabian Kosmale2021-11-251-2/+5
| | | | | | | | | | The compiler runs out of memory and fails to compile tst_qmetatype.cpp. Set TST_QMETATYPE_BROKEN_COMPILER from a previous compiler workaround for QNX to disable the most expensive part of the test. Task-number: QTQAINFRA-4669 Change-Id: I3a99b6b790dc074e9d1db262e758555fb45e4331 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* tst_qmetatype: Fix operator< detection for std::optionalFabian Kosmale2021-09-211-0/+2
| | | | | | | | | | Amends ca54b741d6edda24773137aacee229db31dd3585. operator< is not constrained in MSVC's standard library, either. Pick-to: 6.2 Fixes: QTBUG-96690 Change-Id: Ibcbb9e53a1f9e8b13786f6d8c01489c61d8d2d7f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* normalizeTypeFromSignature: Beware of anonymous struct/unionFabian Kosmale2021-06-081-0/+15
| | | | | | | | | | | | | | | | | | Do a quick check whether the type name contains an anonymous type. If so, do not try to use optimized version. The simple check should still be faster than calling normalizeType unconditionally. Also only apply the faster version for clang and gcc, instead of all non-MSVC compilers. Applying it to other compilers would require further testing to handle anonymous structs. Moreover, remove space before '(', which is necessary for function pointers. Fixes: QTBUG-94213 Change-Id: I795d1964f7a68daa6f9a5f262816d51ee7728788 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QTypeInfo: Handle T::value_type being equal to TFabian Kosmale2021-03-251-0/+10
| | | | | | | | | | | | | | | | | Fix operator checks for containers whose value_type equals themselves. It does not make sense to recurse on value_type in that case. Thanks to std::disjunction having short-circuiting semantics, we can avoid that issue by checking first whether T is T::value_type. As a drive-by, check for value_type typedef before checking for begin/end in is_container. This works around an issue in gcc <= 8.1, which fails to correctly SFINAE the case where begin and end are private methods. Pick-to: 6.0 6.1 Fixes: QTBUG-89456 Change-Id: I27305a7cfe050f13a279c07f00bc229c01daa25b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tst_qmetatype: RELOCATABLE -> PRIMITIVE is binary compatibleFabian Kosmale2021-03-051-1/+10
| | | | | | | | Based on the discussion in https://codereview.qt-project.org/c/qt/qtbase/+/336742 changing our types from RELOCATABLE to PRIMITVE is fine. Change-Id: Ica867203aa813d19fdfd3753fc4ff36ef4332fc3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QMetaType: Store QMetaObject for pointer to const QObject, tooFabian Kosmale2021-02-262-0/+20
| | | | | | | | | | | | | | | | | Before this change, the QMetaType for T const* where T is derived from QObject would not store the static QMetaObject of T. This commit changes this. As a consequence, the metatype system can now convert between const and non-const pointers to QObject. Note that this allows casting const away; but so does C++ with const_cast. In addition, a new flag, QMetaType::IsImmutable is introduced, and used to tag the metatypes of pointer to const types. This allows code to discern between pointers to mutable and const QObjects, which is relevant for the QML engine. Task-number: QTBUG-82354 Change-Id: I3e4e4f39f565bd99a65e161528ce5304df73d6d6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>