[cfe-dev] Parent of an AST node?

Nico Weber nicolasweber at gmx.de
Fri Aug 1 11:43:23 PDT 2008


Hi Ted,

On 01.08.2008, at 01:25, Ted Kremenek wrote:

> Hi Nico,
>
> Check out the ParentMap class in libAST.  It represents a map from  
> Stmt* -> Stmt* (children to parents).  To construct it, you just  
> provide the root of the AST:
>
>  ParentMap PM(root);
>
> To query for a parent:
>
>  Stmt* parent = PM.getParent(child);

thanks, that class contains nearly exactly the code I wrote myself :-)

Unrelated: Is there "the" root of the AST? As far as I understand,  
there's only a forrest of ASTs, with TranslationUnit storing their  
roots (TranslationUnitDecl has a FIXME that this might change in the  
future).

Nico



More information about the cfe-dev mailing list