I can traverse the specific subtrees of clang AST using the recursivevisitor class but what I want to do is to traverse the clang AST node by node.
I'd be really grateful if anybody can help me with this.
Thanks in advance.
I can traverse the specific subtrees of clang AST using the recursivevisitor class but what I want to do is to traverse the clang AST node by node.
I'd be really grateful if anybody can help me with this.
Thanks in advance.
RecursiveASTVisitor can do what you need.
Implementing the member methods
TraverseDecl(Decl *x)
,TraverseStmt(Stmt *x)
andTraverseType(QualType x)
for your RecursiveASTVisitor`-derived class (e.g. MyClass) will do the trick. Combined, those three methods will take you to each and every node in your AST.Example: