[cfe-dev] Need Help Printing Preprocessed Code and Modifying CFG
Ted Kremenek
kremenek at apple.com
Thu Jul 4 11:16:03 PDT 2013
On Jul 4, 2013, at 10:46 AM, Kevin Boos <kevinaboos at gmail.com> wrote:
> 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.
Hi Kevin,
I think David addressed this point pretty well. If you goal is source-to-source translation, there is no need to modify the original AST. Instead, generate “edits” to the original source by deleting the old source range and inserting new source code. You can then emit edits + original source. There are several examples of rewriters like this in the Clang tree, such as the Objective-C rewriter, etc., that take this approach. The nice thing about this approach is that it preserves comments, and essentially all elements of the original source that you didn’t need to touch.
Ted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130704/fcb9f5e7/attachment.html>
More information about the cfe-dev
mailing list