RecursiveASTVisitor can do what you need.
Implementing the member methods TraverseDecl(Decl *x) , TraverseStmt(Stmt *x) and TraverseType(QualType x) for your derived class RecursiveASTVisitor (e.g. MyClass) will do the trick. Combined, these three methods will lead you to each node in your AST.
Example:
class MyClass : public RecursiveASTVisitor<MyClass> { public: bool TraverseDecl(Decl *D) {
source share