<p dir="ltr">Attempting source to source transformations this way (via the ast/cfg) is generally not recommended. These devices are not intended (and thus don't work very well) for this purpose.</p>
<p dir="ltr">What's the goal of transforming the source in this way? If you're trying to instrument/test the resulting program behavior, consider an approach like the sanitizers (address/memory/thread sanitizer) that instruments code within clang's generation phase. If you're attempting to rewrite code, consider something like the ASTMatchers & tooling library.</p>
<div class="gmail_quote">On Jul 2, 2013 7:06 PM, "Kevin Boos" <<a href="mailto:kevinaboos@gmail.com">kevinaboos@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hello all,<div><br></div><div>I'm working with a Clang plugin (it must be a plugin for kernel compilation reasons) that analyzes drivers in the Linux kernel for virtualization security purposes. </div><div>
<br></div><div>I start by modifying the body of a function in a way that certain statements are deleted. Then I need to print out that modified source code so that it can be compiled and preferably human-readable. However, I want to expand all macros so that there are minimal external symbols in the generated code. I tried using the Rewriter class for this, but the Rewriter apparently prints out original source code only and cannot expand macros... <b>is there an alternative source printer that can print the preprocessed code? </b></div>
<div>For reference, when calling "printPretty()" on the function's body Stmt*, the macros are expanded just like I want. </div><div><br></div><div>My second question is about actually deleting those certain statement nodes in a CFG. I remember reading somewhere in the Clang docs that the CFG is a constant data structure that can't be modified.<b> Is there a way to delete statements from the underlying AST so that they wouldn't appear in the CFG and also not appear in the re-printed source code? </b> To be clear, I'm using the CFG for other analysis reasons, but I don't really care if the Stmt nodes are deleted from the AST directly or from inside a CFG basic block.<br>
<br>Thanks in advance,</div><div>Kevin Boos</div><div>Rice University Ph.D. Candidate</div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div>