Reflection from AST?


similar to my other question, but different enough to start a separate thread: I need to get e.g. the offsets of data members in classes, of base classes, and the size of a class. Would the AST be the right place? I cannot find that data anywhere in there - is it too "early", do I have to look at IR? Is there maybe an example anywhere?

Cheers, Axel.

Given an ASTContext you can use Ctx.getASTRecordLayout(D) to get the layout information for a record decl. This is needed for C semantic analysis because sizeof() must be evaluatable.


ASTContext::getASTRecordLayout returns the layout of a class.

  - Doug

Hi Doug and Chris,

thanks SO much! Amazing, it's all there!

Cheers, Axel.