How can I get details of QualType within Clang AST?

Follow this interesting question on StackOverflow, I always check whether a type is canonical, and get its canonical Type. But how can I get the detail of the struct type, the definition of this canonical Type if it’s not a BuiltinType? For example, the fields in definition of struct _poire: int g, tomate rouge?

struct _poire {
int g;
tomate rouge;
};

I read the document of clang QualType but I haven’t found the answer yet.

Thank you for your answers!

Hi @russell . From a QualType, you can call getTypePtr (or getTypePtrOrNull), which will get you the underlying clang::Type. Then you can use the functions on clang::Type to interpret it appropriately. For example, getAsCXXRecordDecl().

Hope this helps.