[cfe-dev] Could I get the Parent AST of a Stmt?
Kirill Bobyrev via cfe-dev
cfe-dev at lists.llvm.org
Fri Jan 1 05:10:37 PST 2016
As far as I understand the issue:
1. You might want to pass **string* to the *ASTContext::getParents()*
function as it doesn't accept pointer to the AST node of any kind.
2. *ASTContext::getParents()* returns *DynTypedNodeList* and it can't be
implicitly converted into a *ParentVector*.
Hope that helps,
Kirill Bobyrev
On 1/1/2016 11:52 AM, 周书林 wrote:
> I am trying to use clang::ASTContext::getParents(), but there are some
> problems.
> I wrote a sample code as follows, try to get the Parent of StringLiteral:
> 内嵌图片 5
>
> But when I try to compile my source code, it report a error as follows:
> 内嵌图片 4
>
> What is the problem? Is there no pre-established ParentMap?
> Thank you very much!
>
>
>
> 2016-01-01 15:47 GMT+08:00 Kirill Bobyrev via cfe-dev
> <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>>:
>
> Hi!
>
> 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 <mailto: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 <mailto:cfe-dev at lists.llvm.org>
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org <mailto: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/087294ed/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 16871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160101/087294ed/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 145922 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160101/087294ed/attachment-0001.png>
More information about the cfe-dev
mailing list