The Clang AST is great, but it's a bit tedious to look at at a node
and then try to find a suitable piece of C++ code to trigger it.
Does anyone know of an easier way to play with the AST? For example
documentation or such that says NamedDecl -> and here is how to create
a NamedDecl in C++?
And then I'm also sometimes lost on what can appear inside a Node,
i.e. a Decl node can have VarDecl and that can have a
CXXConstructExpr, etc.
Even if some of you have tips to share, that'd be great.
Looking at the inheritance diagram should give you a good idea about what each node represents. NamedDecl is a base class for all declarations that have a name. So for example:
int x; // variable declaration VarDecl that’s also a NamedDecl
foo: // label LabelDecl that’s also a NamedDecl
namespace bar {} // you get the idea
I think the solution to that is better documentation. Every node in the AST should ideally have a comment that explains what kinds of syntactic constructs it represents, with examples (some have them already). Unfortunately that’s a huge project.