<p dir="ltr">If you don't want to rewrite code (ie. If you have no need for source code to come out of this process), don't. If you want to instrument code to track various runtime properties like adding extra checks, profiling, etc - do that with IR. See, for example, how the sanitizers (ubsan, msan, as an) are implemented. Either as pure IR transformations, or as extra IR generates by clang</p>
<div class="gmail_quote">On Jan 23, 2013 9:50 PM, "JohnH" <<a href="mailto:jan.hoogerbrugge@gmail.com">jan.hoogerbrugge@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">
Hi,<br>
<br>
I am new to clang so perhaps this is a beginners question....<br>
<br>
I am trying to add some instrumentation code and I want to use a plugin for<br>
that. I use Rewriter to<br>
build new code where the new code consists of pretty printed ASTs with my<br>
own instrumentation<br>
code. Is this the way to do this? The first problem that I encountered is<br>
that the new code is not<br>
passed further down the compilation chain but gets stored in a<br>
RewriteBuffer. Should I somehow<br>
re-parse this code?<br>
<br>
Is tooling::RefactoringTool a better method to use than Rewriter? If so, are<br>
there examples available?<br>
<br>
Finally a question about plugins. Are they compatible between clang<br>
versions? (I am afraid that they are not).<br>
<br>
Regards,<br>
John<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://clang-developers.42468.n3.nabble.com/AST-transformations-in-a-plugin-tp4029993.html" target="_blank">http://clang-developers.42468.n3.nabble.com/AST-transformations-in-a-plugin-tp4029993.html</a><br>
Sent from the Clang Developers mailing list archive at Nabble.com.<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>
</blockquote></div>