[cfe-dev] Need Help Printing Preprocessed Code and Modifying CFG
Béatrice Creusillet
bac at silkan.com
Thu Jul 4 00:11:15 PDT 2013
Hi Kevin,
Le 03/07/2013 20:00, Kevin Boos a écrit :
> I've looked into the ASTMatcher's abilities, those are very nice but not
> terribly useful for me.
>
> I think I've narrowed down what I really need from Clang -- the ability
> to delete a note from the AST/CFG and then output that modified AST as
> source code.
>
> I know that I can printPretty() the source code of an AST or use the
> Rewriter to generate the code. So basically I just need to know how to
> remove a Stmt or other node from the AST/CFG.
Although this is not usually recommended, it is possible to remove nodes
of the AST, for instance using TreeTransform. If your node is part of a
sequence of statements, you basically build a new vector of statements
-- without the nodes you don't need -- in your own version of
TransformCompoundStmt, and then rebuild the underlying tree using
RebuildCompoundStmt. There has been a thread about that earlier this year.
Regards,
--
Béatrice Creusillet
SILKAN - www.silkan.com
More information about the cfe-dev
mailing list