1

I have dump the AST Tree of a simple C++ codes. enter image description here

Is it possible to only visit the nodes selected and ignore everything else including the children using libTooling or ASTMatchers?

HiWorld
  • 31
  • 7

1 Answers1

1
  • Find any stmt (or a subclass of statements good for you)
  • Add a condition that they hasParent, probably a CompundStmt based on your example.
  • Again based on your example, you probably want to enforce that the CompundStmt hasParent, which is a FunctionDecl

See the AST matchers reference for details.

Dutow
  • 5,638
  • 1
  • 30
  • 40