Okay, as Mat Petersson Adviced, I experimented.
1) Yes, the AST is generated after the preprocessor. It permit to retrieve all the informations.
2) The AST traversal is depth-first. Rather than implement VisitFoo(Foo *)
methods, you can reimplement TraverseFoo(Foo *)
method to get the begin and the end of each node lookup :
class YourVisitor : public RecursiveASTVisitor<YourVisitor>
{
//...
virtual bool TraverseFoo(Foo * f)
{
//Some stuff to do before to explore the children
bool r = RecursiveASTVisitor<YourVisitor>::TraverseFoo(f);
//Some stuff to do after
return r
}
}
Then to get the structs ( = records) and their members, just to re-implement TraverseRecordDecl to handle the struct and VisitFieldDecl to get the fields.