Jeremy Kuah
Jeremy Kuah

Reputation: 539

VisitDecl vs. TraverseDecl (Clang RecursiveASTVisitor)

I've read this link but still don't fully understand what's the difference between TraverseDecl and VisitDecl (and their use case) http://clang.llvm.org/doxygen/classclang_1_1RecursiveASTVisitor.html

Which method should I be overriding when writing my RecursiveASTVisitor?

Upvotes: 8

Views: 3801

Answers (1)

Nishant Sharma
Nishant Sharma

Reputation: 693

TraverseDecl tells the frontend library's ASTConsumer to visit declarations recursively from the AST. Then VisitDecl is called where you can extract the relevant information.

Follow these two links for more details and a simple checker example:

http://clang.llvm.org/docs/RAVFrontendAction.html

How to traverse clang AST manually ?

Upvotes: 5

Related Questions