From 7c647edae928d27343b64b5e0f0805920b754110 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 20 Feb 2017 13:50:35 +0100 Subject: QTypeInfo: don't treat enums and (extended) integral types as complex We fully specialize QTypeInfo for most C++ built-in types, but enums and extended integral types (like GCC's int128_t) were not covered. Now that we depend on , we can stop pessimizing enums and extended integral types in QVector and QVLA by defaulting QTypeInfo::isComplex to true for such types. Fix a test that checked that enums were complex types. This should have been a XFAIL test. Enums are not complex types. Change-Id: Ibb0fb38cc83e980a428b5573d1db5666593418ae Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qtypeinfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/global/qtypeinfo.h') diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 53f6b3fff6..cbba253a75 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -60,7 +60,7 @@ public: enum { isPointer = false, isIntegral = std::is_integral::value, - isComplex = true, + isComplex = !isIntegral && !std::is_enum::value, isStatic = true, isRelocatable = std::is_enum::value, isLarge = (sizeof(T)>sizeof(void*)), -- cgit v1.2.3 From 3ac8b8c6961bb5b2ae82bbaee154282c54bd0b90 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 20 Feb 2017 09:36:34 +0100 Subject: QTypeInfo: record whether it was specialized This is one of the pillars of my static container checking toolbox, one of the main checks being that every type put into a Qt container has been marked up with Q_DECLARE_TYPEINFO. Obviously, we cannot upstream such a checker and inflict it upon the world, but we can put some foundations in. This is the most central one. Change-Id: I9185facb2f37ba9fcc12c9aae5675eed454d755c Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thiago Macieira --- src/corelib/global/qtypeinfo.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/corelib/global/qtypeinfo.h') diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index cbba253a75..7031021e16 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -58,6 +58,7 @@ class QTypeInfo { public: enum { + isSpecialized = std::is_enum::value, // don't require every enum to be marked manually isPointer = false, isIntegral = std::is_integral::value, isComplex = !isIntegral && !std::is_enum::value, @@ -74,6 +75,7 @@ class QTypeInfo { public: enum { + isSpecialized = true, isPointer = false, isIntegral = false, isComplex = false, @@ -90,6 +92,7 @@ class QTypeInfo { public: enum { + isSpecialized = true, isPointer = true, isIntegral = false, isComplex = false, @@ -152,6 +155,7 @@ class QTypeInfoMerger { public: enum { + isSpecialized = true, isComplex = QTypeInfoQuery::isComplex || QTypeInfoQuery::isComplex || QTypeInfoQuery::isComplex || QTypeInfoQuery::isComplex, isStatic = QTypeInfoQuery::isStatic || QTypeInfoQuery::isStatic @@ -173,6 +177,7 @@ class QTypeInfo< CONTAINER > \ { \ public: \ enum { \ + isSpecialized = true, \ isPointer = false, \ isIntegral = false, \ isComplex = true, \ @@ -201,6 +206,7 @@ class QTypeInfo< CONTAINER > \ { \ public: \ enum { \ + isSpecialized = true, \ isPointer = false, \ isIntegral = false, \ isComplex = true, \ @@ -241,6 +247,7 @@ class QTypeInfo \ { \ public: \ enum { \ + isSpecialized = true, \ isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0), \ isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), \ isRelocatable = !isStatic || ((FLAGS) & Q_RELOCATABLE_TYPE), \ -- cgit v1.2.3