Consider two typedefs
struct A { int member; };
typedef struct A TA;
typedef struct B { int b; } TB;
One can ask libclang for the type underlying the typedef (using clang_getTypedefDeclUnderlyingType(CXCursor)
) for both examples.
In both cases we get a CXType with kind CXType_Elaborated
.
Question: Given those elaborated type nodes, how do I then distinguish a declaration (like the struct A
) from a definition (like the struct B { int b; }
)?
The possibly relevant libclang functions appear to be:
CXType clang_Type_getNamedType(CXType)
CXCursor clang_getTypeDeclaration(CXType)
clang_Type_visitFields(CXType)
But I have not discovered a way to use these to make the distinction between the two kinds of typedefs. The distinction is relevant to be able to pretty print the typedefs again in the same way that it was written in the program.