[cfe-dev] Back-navigation of the Syntax Tree!
Simone Pellegrini
spellegrini at dps.uibk.ac.at
Thu Jan 29 07:55:07 PST 2009
Dear all,
I need to make some kind of manipulation of a syntax tree in Clang.
Actually what I want to do is just move some statement (mainly the
entire line... until the ';' which enclose a statement I want to move).
Apparently this kind of work is more complex than what I thought.
At the beginning I perform a simple data-flow analysis to determine the
positions where the statement can be placed (and that's is quite
trivial). It can be easily done by using a visitor of the AST, but for
example when I found, let's say a DeclRefExpr I'd like to have the
possibility to access to the statement that encloses the var reference.
Practically, what I need is the possibility from a statement to access
to the PARENT! I know that I can manually save a reference to the parent
node before entering into a node and that will solve my problem but it
is ugly! :) Is this possible with the current API to access the parent
of a node? I searched a lot and there is no way to get this information.
regards Simone
More information about the cfe-dev
mailing list