Index: bindings/python/clang/cindex.py =================================================================== --- bindings/python/clang/cindex.py +++ bindings/python/clang/cindex.py @@ -1673,6 +1673,7 @@ TypeKind.VARIABLEARRAY = TypeKind(115) TypeKind.DEPENDENTSIZEDARRAY = TypeKind(116) TypeKind.MEMBERPOINTER = TypeKind(117) +TypeKind.ELABORATED = TypeKind(118) class RefQualifierKind(BaseEnumeration): """Describes a specific ref-qualifier of a type.""" @@ -1871,6 +1872,12 @@ """ return conf.lib.clang_Type_getClassType(self) + def getElabaratedTypeUnderlyingType(self): + """ + Retrieve the inner type of the elaborated type + """ + return conf.lib.clang_getElabaratedTypeUnderlyingType(self) + def get_align(self): """ Retrieve the alignment of the record. @@ -3113,6 +3120,11 @@ Type, Type.from_result), + ("clang_getElabaratedTypeUnderlyingType", + [Type], + Type, + Type.from_result), + ("clang_getEnumConstantDeclUnsignedValue", [Cursor], c_ulonglong), Index: include/clang-c/Index.h =================================================================== --- include/clang-c/Index.h +++ include/clang-c/Index.h @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 30 +#define CINDEX_VERSION_MINOR 31 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 10000) \ @@ -2855,7 +2855,8 @@ CXType_IncompleteArray = 114, CXType_VariableArray = 115, CXType_DependentSizedArray = 116, - CXType_MemberPointer = 117 + CXType_MemberPointer = 117, + CXType_Elaborated = 118 }; /** @@ -3220,6 +3221,12 @@ CINDEX_LINKAGE long long clang_getArraySize(CXType T); /** + * \brief Return the inner type of elaborated type + * + * If a non-elaborated type passed, CXType_Invalid type returned + */ +CXType clang_getElabaratedTypeUnderlyingType(CXType T); +/** * \brief List the possible error codes for \c clang_Type_getSizeOf, * \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and * \c clang_Cursor_getOffsetOf. Index: test/Index/print-type.c =================================================================== --- test/Index/print-type.c +++ test/Index/print-type.c @@ -12,6 +12,9 @@ int f2(int incompletearray[]); +enum Enum{i}; enum Enum elaboratedEnumType(); +struct Struct{}; struct Struct elaboratedStructType(); + // RUN: c-index-test -test-print-type %s | FileCheck %s // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProto] [resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] [Pointer] [FooType] [Typedef] [int [5]] [ConstantArray] [void (*)(int)] [Pointer]] [isPOD=0] // CHECK: ParmDecl=p:3:13 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int] @@ -45,3 +48,8 @@ // CHECK: VarDecl=x:10:38 [type=__attribute__((__vector_size__(4 * sizeof(int)))) int] [typekind=Vector] [isPOD=1] // CHECK: TypedefDecl=int4_t:11:46 (Definition) [type=int4_t] [typekind=Typedef] [canonicaltype=__attribute__((__vector_size__(4 * sizeof(int)))) int] [canonicaltypekind=Vector] [isPOD=1] // CHECK: ParmDecl=incompletearray:13:12 (Definition) [type=int []] [typekind=IncompleteArray] [isPOD=1] +// CHECK: FunctionDecl=elaboratedEnumType:15:25 [type=enum Enum ()] [typekind=FunctionNoProto] [canonicaltype=enum Enum ()] [canonicaltypekind=FunctionNoProto] [resulttype=enum Enum] [resulttypekind=Elaborated] [isPOD=0] +// CHECK: TypeRef=enum Enum:15:6 [type=enum Enum] [typekind=Enum] [isPOD=1] +// CHECK: StructDecl=Struct:16:8 (Definition) [type=struct Struct] [typekind=Record] [isPOD=1] +// CHECK: FunctionDecl=elaboratedStructType:16:32 [type=struct Struct ()] [typekind=FunctionNoProto] [canonicaltype=struct Struct ()] [canonicaltypekind=FunctionNoProto] [resulttype=struct Struct] [resulttypekind=Elaborated] [isPOD=0] +// CHECK: TypeRef=struct Struct:16:8 [type=struct Struct] [typekind=Record] [isPOD=1] Index: test/Index/print-type.cpp =================================================================== --- test/Index/print-type.cpp +++ test/Index/print-type.cpp @@ -48,6 +48,8 @@ }; int Blob::*member_pointer; +namespace NS { struct Type{}; } NS::Type elaboratedNamespaceType(); + // RUN: c-index-test -test-print-type %s -std=c++11 | FileCheck %s // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] [isPOD=0] // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] [isPOD=0] @@ -61,7 +63,7 @@ // CHECK: Namespace=inner:14:11 (Definition) [type=] [typekind=Invalid] [isPOD=0] // CHECK: StructDecl=Bar:16:8 (Definition) [type=outer::inner::Bar] [typekind=Record] [isPOD=0] [nbFields=3] // CHECK: CXXConstructor=Bar:17:3 (Definition) [type=void (outer::Foo *){{.*}}] [typekind=FunctionProto] [canonicaltype=void (outer::Foo *){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [outer::Foo *] [Pointer]] [isPOD=0] -// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Unexposed] +// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Elaborated] // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0] // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0] // CHECK: CompoundStmt= [type=] [typekind=Invalid] [isPOD=0] @@ -119,3 +121,6 @@ // CHECK: StructDecl=Blob:45:8 (Definition) [type=Blob] [typekind=Record] [isPOD=1] [nbFields=2] // CHECK: FieldDecl=i:46:7 (Definition) [type=int] [typekind=Int] [isPOD=1] // CHECK: VarDecl=member_pointer:49:12 (Definition) [type=int Blob::*] [typekind=MemberPointer] [isPOD=1] +// CHECK: FunctionDecl=elaboratedNamespaceType:51:42 [type=NS::Type ()] [typekind=FunctionProto] [canonicaltype=NS::Type ()] [canonicaltypekind=FunctionProto] [resulttype=NS::Type] [resulttypekind=Elaborated] [isPOD=0] +// CHECK: NamespaceRef=NS:51:11 [type=] [typekind=Invalid] [isPOD=0] +// CHECK: TypeRef=struct NS::Type:51:23 [type=NS::Type] [typekind=Record] [isPOD=1] Index: tools/libclang/CXType.cpp =================================================================== --- tools/libclang/CXType.cpp +++ tools/libclang/CXType.cpp @@ -90,6 +90,7 @@ TKCASE(DependentSizedArray); TKCASE(Vector); TKCASE(MemberPointer); + TKCASE(Elaborated); default: return CXType_Unexposed; } @@ -484,6 +485,7 @@ TKIND(DependentSizedArray); TKIND(Vector); TKIND(MemberPointer); + TKIND(Elaborated); } #undef TKIND return cxstring::createRef(s); @@ -977,4 +979,14 @@ return 0; } +CXType clang_getElabaratedTypeUnderlyingType(CXType CT){ + QualType T = GetQualType(CT); + const Type *TP = T.getTypePtrOrNull(); + + if (TP && TP->getTypeClass() == Type::Elaborated) + return MakeCXType(cast(TP)->getNamedType(), GetTU(CT)); + + return MakeCXType(QualType(), GetTU(CT)); +} + } // end: extern "C" Index: tools/libclang/libclang.exports =================================================================== --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -190,6 +190,7 @@ clang_getDiagnosticSeverity clang_getDiagnosticSpelling clang_getElementType +clang_getElabaratedTypeUnderlyingType clang_getEnumConstantDeclUnsignedValue clang_getEnumConstantDeclValue clang_getEnumDeclIntegerType