How could I visit the same AST?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How could I visit the same AST?

Neil Nelson via cfe-dev
I am learning to visiting ast to collect some information by API of libTooling.
When I process the source file of postfix-3.0.3/src/global/mail_params.c, I met something strange.
When I visit the AST by VisitStmt(), I could find that there would be a sub level of "InitListExpr" in the first level of "InitListExpr" as attachment shown.

However, when I want to visit the parent AST of StringLiteral by VisitStringLiteral(), the sub level of "InitListExpr" is gone, I can only get the higher level "InitListExpr".
I get the parent AST by using "CompilerInstance.getASTContext().getParents(Stmt*)".
So, how to visit the same AST in these two methods?
Thank you a lot !

cfe-dev mailing list
[hidden email]

example.jpg (64K) Download Attachment