[cfe-dev] Determine parent/child relationships in RecursiveASTVisitor

Nikola Smiljanic popizdeh at gmail.com
Wed Oct 1 18:30:49 PDT 2014


This information should be available from ASTContext::getParents.

On Thu, Oct 2, 2014 at 6:56 AM, Aaron W. Hsu <arcfide at sacrideo.us> wrote:

> Dear Clang Dev:
>
> I have a RecursiveASTVisitor. I'd like to know the relative relationship
> between a node I'm currently visiting with the previous node visited.
> Basically, I'm trying to write a visitor which gives back an array of
> the depths of each node during the traversal. So, if a node is a child
> of the previously visited node, then its depth is 1 more than the depth
> of the previous node, and if it is a sibling it is the same. If it is a
> cousin of some sort, it's more difficult, and I would need to know just
> how far away that node is from the previous.
>
> Another approach would be to just determine this depth directly given a
> node and walk up it's parent chain to the root. I'm find with doing this
> as well, but I can't seem to find something that gives me the parent of
> a node.
>
>   Yours truly,
>       Aaron W. Hsu
>
> --
> Aaron W. Hsu | arcfide at sacrideo.us | http://www.sacrideo.us
> Please support my work: https://www.gratipay.com/arcfide/
> לֵ֤ב חֲכָמִים֙ בְּבֵ֣ית אֵ֔בֶל וְלֵ֥ב כְּסִילִ֖ים בְּבֵ֥ית שִׂמְחָֽה׃
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141002/8467cb20/attachment.html>


More information about the cfe-dev mailing list