[cfe-dev] Question of RecursiveASTVisitor class
xchen422 at uwo.ca
Sun Nov 2 17:32:12 PST 2014
My name is Xiaohui Chen, a computer science student in UWO in canada and i am using Clang as the frontend of my project, but i am confusing of the following statements.
PS: i am a newbie.
These tasks are done by three groups of methods, respectively: 00089 /// 1. TraverseDecl(Decl *x) does task #1. It is the entry point 00090 /// for traversing an AST rooted at x. This method simply 00091 /// dispatches (i.e. forwards) to TraverseFoo(Foo *x) where Foo 00092 /// is the dynamic type of *x, which calls WalkUpFromFoo(x) and 00093 /// then recursively visits the child nodes of x. 00094 /// TraverseStmt(Stmt *x) and TraverseType(QualType x) work 00095 /// similarly. 00096 /// 2. WalkUpFromFoo(Foo *x) does task #2. It does not try to visit 00097 /// any child node of x. Instead, it first calls WalkUpFromBar(x) 00098 /// where Bar is the direct parent class of Foo (unless Foo has 00099 /// no parent), and then calls VisitFoo(x) (see the next list item). 00100 /// 3. VisitFoo(Foo *x) does task #3. 00101 /// 00102 /// These three method groups are tiered (Traverse* > WalkUpFrom* > 00103 /// Visit*). A method (e.g. Traverse*) may call methods from the same 00104 /// tier (e.g. other Traverse*) or one tier lower (e.g. WalkUpFrom*). 00105 /// It may not call methods from a higher tier.
According to the above statement, the calling relationship between these
functions are organized in this way in general:
am i right?
For this statement:
00096 /// 2. WalkUpFromFoo(Foo *x) does task #2. It does not try to visit 00097 /// any child node of x. Instead, it first calls WalkUpFromBar(x) 00098 /// where Bar is the direct parent class of Foo (unless Foo has 00099 /// no parent), and then calls VisitFoo(x) (see the next list item).
what do you mean by saying "the direct parent class of Foo"?
why i need to visit the parent class before i visit the current class?
what is the purpose? Could you please give me a short example?
Thank you in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev