[cfe-dev] Need Help Printing Preprocessed Code and Modifying CFG

Kevin Boos kevinaboos at gmail.com
Thu Jul 4 10:46:01 PDT 2013


Hi Ted,

Thanks for the reply. Now I think I understand the relationship between the
AST and CFG. I won't attempt to directly modify the CFG, which I had
previously assumed to be immutable due to all the const usage throughout
its methods.

So, if I was examining a CFGBlock, for example, I could access the
underlying AST Stmt nodes and operate on them.

Now, once I have access to the AST node, what is a good way to remove it
from the AST? (Ideally in a clean manner)....  I assume this is possible
because I have seen several prior works that use Clang for refactoring, and
many refactoring operations involve deleting or at least
replacing/reordering nodes.

Best,
Kevin
 On Jul 4, 2013 12:23 PM, "Ted Kremenek" <kremenek at apple.com> wrote:

> On Jul 3, 2013, at 11:00 AM, Kevin Boos <kevinaboos at gmail.com> wrote:
>
> 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.
>
>
> Hi Kevin,
>
> Responding to just the comment, the CFG should be viewed as a data
> structure that is lazily constructed from the AST.  It is a “view” on the
> AST, but it shouldn’t be viewed as something you can mutate.  Also, the CFG
> may contain AST elements not in the original AST (particularly DeclStmts)
> for purposes of easier analysis.  This latter part is something we may wish
> to change in the future by adding new CFGElements, but that’s something
> that is currently done now.
>
> Ted
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130704/c0c098b9/attachment.html>


More information about the cfe-dev mailing list