<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Jul 13, 2016 at 3:34 PM Farzad Sadeghi via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
I need to travel through all the ancestors or descendants of a matched<br>
AST node to later use that info to moodify parts of the input source<br>
code. I tried to look for ways to do that. I looked at the getParents<br>
member function of the ASTContext class. I could use that to just go<br>
up the AST hierarchy to visit all the ancestor nodes of my<br>
currently-matched node. but the problem with that is, when i get the<br>
parent node, i no longer have the context for that node to try and get<br>
its parent.</blockquote><div><br></div><div>The ASTContext is independent of the node - you can still use the same ASTContext.</div><div><br></div><div>Note that you also have hasAncestor AST matchers, and you can run AST matchers directly on a node inside a MatchCallback.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> I could try to rebuild the ASTContext for the new node but<br>
that seems to be another big task on its own, if possible. the lowest<br>
NodeKind (lowest in the C hierarchy) I'm looking for is a callExpr and<br>
the highest I'm looking for is a functionDecl. How can I obtain all<br>
the ancestors or descendants of a matched AST node after the match<br>
returns the control to run in MatchCallback?<br>
<br>
<br>
--<br>
Farzad Sadeghi<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>