aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-06-13 09:52:53 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-06-15 19:59:10 +0200
commite4cd729f752fab69e01993d304bd73cd7fe41baa (patch)
tree058f34fbfc865b1e97828e3ce34de163af72df76 /sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp
parent9c7f990f8d2d71650b11c6913c4d7c4118eccad6 (diff)
shiboken6: Fix determining unsigned enum values for enums with typedefs as underlying types
In case of enums with typedefs as underlying types, for example: enum GlyphRunRetrievalFlag : quint16 { RetrieveAll = 0xffff the unsignedness-detection would fail. Add helper functions to fully resolve typedefs for this case. Pick-to: 6.5 Task-number: PYSIDE-1735 Change-Id: Ib42c4a5b34cb576a8246f4734d4ae8dacb9ac2e7 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp
index dbea15f3d..aafa79cca 100644
--- a/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp
+++ b/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp
@@ -113,7 +113,7 @@ static inline bool isBuiltinType(CXTypeKind kind)
}
// Resolve elaborated types occurring with clang 16
-static CXType resolveType(const CXType &type)
+static CXType resolveElaboratedType(const CXType &type)
{
if (!isBuiltinType(type.kind)) {
CXCursor decl = clang_getTypeDeclaration(type);
@@ -124,6 +124,26 @@ static CXType resolveType(const CXType &type)
return type;
}
+// Resolve typedefs
+static CXType resolveTypedef(const CXType &type)
+{
+ auto result = type;
+ while (result.kind == CXType_Typedef) {
+ auto decl = clang_getTypeDeclaration(result);
+ auto resolved = clang_getTypedefDeclUnderlyingType(decl);
+ if (resolved.kind == CXType_Invalid)
+ break;
+ result = resolved;
+ }
+ return result;
+}
+
+// Fully resolve a type from elaborated & typedefs
+CXType fullyResolveType(const CXType &type)
+{
+ return resolveTypedef(resolveElaboratedType(type));
+}
+
QString getTypeName(const CXType &type)
{
CXString typeSpelling = clang_getTypeSpelling(type);
@@ -146,7 +166,7 @@ bool hasScopeResolution(const CXType &type)
// Resolve elaborated types occurring with clang 16
QString getResolvedTypeName(const CXType &type)
{
- return getTypeName(resolveType(type));
+ return getTypeName(resolveElaboratedType(type));
}
Diagnostic::Diagnostic(const QString &m, const CXCursor &c, CXDiagnosticSeverity s)