summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-06-07 13:59:45 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-06-08 15:37:38 +0200
commitc76a2d7c9cfc5e2edd45a30681df51b37125bc01 (patch)
tree67a361050d53518b26206a11465369d970656c84 /src/corelib
parent14b74af0608dc833f836acac4ee93f905b449806 (diff)
normalizeTypeFromSignature: Beware of anonymous struct/union
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>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qmetatype.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 5e53a970d4..d6fc881d50 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -1879,12 +1879,21 @@ private:
}
public:
-#ifndef Q_CC_MSVC
+#if defined(Q_CC_CLANG) || defined (Q_CC_GNU)
// this is much simpler than the full type normalization below
// the reason is that the signature returned by Q_FUNC_INFO is already
// normalized to the largest degree, and we need to do only small adjustments
constexpr int normalizeTypeFromSignature(const char *begin, const char *end)
{
+ // bail out if there is an anonymous struct
+ std::string_view name(begin, end-begin);
+#if defined (Q_CC_CLANG)
+ if (name.find("anonymous ") != std::string_view::npos)
+ return normalizeType(begin, end);
+#else
+ if (name.find("unnamed ") != std::string_view::npos)
+ return normalizeType(begin, end);
+#endif
while (begin < end) {
if (*begin == ' ') {
if (last == ',' || last == '>' || last == '<' || last == '*' || last == '&') {
@@ -1893,7 +1902,7 @@ public:
}
}
if (last == ' ') {
- if (*begin == '*' || *begin == '&') {
+ if (*begin == '*' || *begin == '&' || *begin == '(') {
replaceLast(*begin);
++begin;
continue;