[cfe-dev] Could I get the Parent AST of a Stmt?

Kirill Bobyrev via cfe-dev cfe-dev at lists.llvm.org
Thu Dec 31 23:47:24 PST 2015


You can get parents of current AST node via calling clang::ASTContext::getParents() <http://clang.llvm.org/doxygen/classclang_1_1ASTContext.html#a32d11844fdb82310b9059784fd4ceb6b>. In order to reach InitListExpr you should walk up several times.

Hope that helps,
Kirill Bobyrev

> On 01 Jan 2016, at 10:16 AM, 周书林 via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> In my clang-tool, I want to do some analysis on AST after visit some specific type of Stmt Node. So I need to go to the parent AST node of current stmt. Is there any member functions of Stmt to archieve this goal?
> For example, I am visiting the AST node StringLiteral "xmloption", how can I get to the Node InitListExpr "config_generic"?(I am using the VisitStringLiteral() function to visit the StringLiteral Node).
> <2016-01-01 15:12:54的屏幕截图.png>
> Thanks a lot!
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160101/6fbfa457/attachment.html>

More information about the cfe-dev mailing list