aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-04-25 14:01:45 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-04-28 10:55:49 +0200
commit44ef1859214c66861a251d4a0faf5c38dc050850 (patch)
tree2da2ff3f53082e7e0d63fae5a5a9a50ba738789d /sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp
parent24742dca014109bd3c2a9775fc15ca306ab22c9c (diff)
shiboken6/clang: Fix build with clang 16
clang 16 returns more elaborated types instead of fully qualified type names. Qualify elaborated types when retrieving the type name. [ChangeLog][shiboken6] Support for libclang version 16 has been added. Task-number: PYSIDE-2288 Pick-to: 6.5 5.15 Change-Id: Ibd428280180967f11d82a72159e744c016afc927 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp
index 142655610..874ba4945 100644
--- a/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp
+++ b/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp
@@ -105,6 +105,23 @@ QString getCursorDisplayName(const CXCursor &cursor)
return result;
}
+static inline bool isBuiltinType(CXTypeKind kind)
+{
+ return kind >= CXType_FirstBuiltin && kind <= CXType_LastBuiltin;
+}
+
+// Resolve elaborated types occurring with clang 16
+static CXType resolveType(const CXType &type)
+{
+ if (!isBuiltinType(type.kind)) {
+ CXCursor decl = clang_getTypeDeclaration(type);
+ auto resolvedType = clang_getCursorType(decl);
+ if (resolvedType.kind != CXType_Invalid && resolvedType.kind != type.kind)
+ return resolvedType;
+ }
+ return type;
+}
+
QString getTypeName(const CXType &type)
{
CXString typeSpelling = clang_getTypeSpelling(type);
@@ -113,6 +130,12 @@ QString getTypeName(const CXType &type)
return result;
}
+// Resolve elaborated types occurring with clang 16
+QString getResolvedTypeName(const CXType &type)
+{
+ return getTypeName(resolveType(type));
+}
+
Diagnostic::Diagnostic(const QString &m, const CXCursor &c, CXDiagnosticSeverity s)
: message(m), source(Other), severity(s)
{