<div dir="ltr">David,<div><br></div><div>Thanks, I'll take a look at ASTMatchers. </div><div><br></div><div>The purposes of the analysis is to generate a subset of the source, where this subset is effectively a slice of statements that affect a given CallExpr (with certain extra statements added into that subset). I realize that slicing is better achieved with LLVM; I have already done this. This needs to be at the source level. My problem is merely how to delete a statement or other type of node from an AST or CFG, and then re-write the preprocessed source as output.</div>

<div><br></div><div>Thanks,</div><div>Kevin</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 3, 2013 at 9:47 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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"><div><div class="h5">On Jul 2, 2013 7:06 PM, "Kevin Boos" <<a href="mailto:kevinaboos@gmail.com" target="_blank">kevinaboos@gmail.com</a>> wrote:<br type="attribution"></div></div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<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></div></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">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>
</blockquote></div><br></div>