aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp3
-rw-r--r--sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp24
-rw-r--r--sources/shiboken6/ApiExtractor/clangparser/clangutils.h1
3 files changed, 25 insertions, 3 deletions
diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp
index 1bc742ae7..3a9dfde40 100644
--- a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp
+++ b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp
@@ -946,7 +946,8 @@ BaseVisitor::StartTokenResult Builder::startToken(const CXCursor &cursor)
d->m_currentEnum->setEnumKind(kind);
if (clang_getCursorAvailability(cursor) == CXAvailability_Deprecated)
d->m_currentEnum->setDeprecated(true);
- d->m_currentEnum->setSigned(isSigned(clang_getEnumDeclIntegerType(cursor).kind));
+ const auto enumType = fullyResolveType(clang_getEnumDeclIntegerType(cursor));
+ d->m_currentEnum->setSigned(isSigned(enumType.kind));
if (std::dynamic_pointer_cast<_ClassModelItem>(d->m_scopeStack.back()))
d->m_currentEnum->setAccessPolicy(accessPolicy(clang_getCXXAccessSpecifier(cursor)));
}
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)
diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangutils.h b/sources/shiboken6/ApiExtractor/clangparser/clangutils.h
index 5cb95b4f9..5cd46812d 100644
--- a/sources/shiboken6/ApiExtractor/clangparser/clangutils.h
+++ b/sources/shiboken6/ApiExtractor/clangparser/clangutils.h
@@ -27,6 +27,7 @@ QString getCursorSpelling(const CXCursor &cursor);
QString getCursorDisplayName(const CXCursor &cursor);
QString getTypeName(const CXType &type);
bool hasScopeResolution(const CXType &type);
+CXType fullyResolveType(const CXType &type);
QString getResolvedTypeName(const CXType &type);
inline QString getCursorTypeName(const CXCursor &cursor)
{ return getTypeName(clang_getCursorType(cursor)); }