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

Aaron W. Hsu arcfide at sacrideo.us
Wed Oct 1 13:56:53 PDT 2014


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/
לֵ֤ב חֲכָמִים֙ בְּבֵ֣ית אֵ֔בֶל וְלֵ֥ב כְּסִילִ֖ים בְּבֵ֥ית שִׂמְחָֽה׃




More information about the cfe-dev mailing list