<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><div><span>Hi Vassil,</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span>I have attempted to debug the Rewriter and CodeGenerator myself and see what happens when compiling, but the amount of code is rather massive and will take some time.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal;
background-color: transparent;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">Here is an running simplified example of what I am doing. Would mind running it and telling me whether it worked for you or not?</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">Cheers,</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal;
background-color: transparent;">Bogdan</div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> On Monday, August 11, 2014 11:18 AM, Bogdan Tabacaru <bogdan.tabacaru88@yahoo.com> wrote:<br> </font> </div> <br><br> <div class="y_msg_container"><div id="yiv8860464091"><div><div style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);"><div><span>That is a good question.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida
Grande', sans-serif; font-style: normal; background-color: transparent;"><span><br clear="none"></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span>I have written a libTool with the same visitor and consumer.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span>I called my_Rewriter.ReplaceText() to make my
AST-transformations.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span>I have output the RewriteBuffer to a new file and then I compiled it.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">When I run the transformed source, it gives me the expected behavior. However, this requires me to explicitly create a new file with the changes.</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br clear="none"></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,
'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">If I do the same thing with the PluginASTAction (with or without re-ordering the Consumers), I only get the behavior from the original source file.</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br clear="none"></div> <div class="yiv8860464091qtdSeparateBR"><br clear="none"><br clear="none"></div><div class="yiv8860464091yqt1498307472" id="yiv8860464091yqt97309"><div class="yiv8860464091yahoo_quoted" style="display: block;"> <div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;"> <div dir="ltr">
<font size="2" face="Arial"> On Monday, August 11, 2014 9:59 AM, Vassil Vassilev <vasil.georgiev.vasilev@cern.ch> wrote:<br clear="none"> </font> </div>
<br clear="none"><br clear="none"> <div class="yiv8860464091y_msg_container"><div id="yiv8860464091"><div>
<div class="yiv8860464091moz-cite-prefix">On 08/10/2014 11:02 AM, Bogdan Tabacaru
wrote:<br clear="none">
</div>
<blockquote type="cite">
</blockquote></div><div><div style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">
<div><span>Hi Vassil,</span></div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span><br clear="none">
</span></div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">thanks for the example and the patch!</div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br clear="none">
</div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">I have applied both of them successfully, but
somehow, re-ordering the consumers still did not give me the
expected results. This means, when I call the plugin it
executes correctly, but CodeGen still only uses the original
file (without the changes made by the plugin).</div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br clear="none">
</div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">Is there another step which I may have
forgotten?</div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br clear="none">
</div>
</div>
If you reorder the consumers in the initialization, it should
work. Are you sure you have the right tests to check for the desired
behaviour? I.e are you sure you are making a valid
AST-transformation?<div class="yiv8860464091yqt6949466389" id="yiv8860464091yqtfd61983"><br clear="none">
Vassil<br clear="none">
<blockquote type="cite">
<div style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">Cheers,</div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">Bogdan</div>
<div class="yiv8860464091qtdSeparateBR"><br clear="none">
<br clear="none">
</div>
<div class="yiv8860464091yahoo_quoted" style="display:block;">
<div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;">
<div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;">
<div dir="ltr"> <font face="Arial" size="2"> On Sunday,
August 10, 2014 12:22 AM, Vassil Vassilev
<a rel="nofollow" shape="rect" class="yiv8860464091moz-txt-link-rfc2396E" ymailto="mailto:vvasilev@cern.ch" target="_blank" href="mailto:vvasilev@cern.ch"><vvasilev@cern.ch></a> wrote:<br clear="none">
</font> </div>
<br clear="none">
<br clear="none">
<div class="yiv8860464091y_msg_container">
<div id="yiv8860464091">
<div>
<div class="yiv8860464091moz-cite-prefix">Hi Bogdan,<br clear="none">
After applying the attached patch, I can do:<br clear="none">
<br clear="none">
void MyPlugin::Initialize(ASTContext& Context)
{<br clear="none">
</div>
</div>
<div> // We need to reorder the consumers in the
MultiplexConsumer.<br clear="none">
MultiplexConsumer& multiplex<br clear="none">
=
static_cast<MultiplexConsumer&>(m_CI.getASTConsumer());<br clear="none">
std::vector<ASTConsumer*>& consumers =
multiplex.getConsumers();<br clear="none">
ASTConsumer* lastConsumer = consumers.back();<br clear="none">
consumers.pop_back();<br clear="none">
consumers.insert(consumers.begin(), lastConsumer);<br clear="none">
}<br clear="none">
<br clear="none">
This allows me to hook MyPlugin before clang's
codegen.<br clear="none">
<br clear="none">
Vassil<br clear="none">
On 09/08/14 21:24, Bogdan Tabacaru wrote:<br clear="none">
<blockquote type="cite"> </blockquote>
</div>
<div class="yiv8860464091yqt7004341515" id="yiv8860464091yqt71669">
<div>
<div style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">
<div><span>Hi Vassil,</span></div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span><br clear="none">
</span></div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span>Is the
patch available for the 3.4.2 version of
LLVM or must I migrate to the "current"
version ?</span></div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span><br clear="none">
</span></div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span>Cheers,</span></div>
<div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span>Bogdan</span></div>
<div class="yiv8860464091qtdSeparateBR"><br clear="none">
<br clear="none">
</div>
<div class="yiv8860464091yahoo_quoted" style="display:block;">
<div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;">
<div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;">
<div dir="ltr"> <font face="Arial" size="2"> On Friday, August 8, 2014
6:16 PM, Vassil Vassilev <a rel="nofollow" shape="rect" class="yiv8860464091moz-txt-link-rfc2396E" ymailto="mailto:vvasilev@cern.ch" target="_blank" href="mailto:vvasilev@cern.ch"><vvasilev@cern.ch></a>
wrote:<br clear="none">
</font> </div>
<br clear="none">
<br clear="none">
<div class="yiv8860464091y_msg_container">
<div id="yiv8860464091">
<div>
<div class="yiv8860464091moz-cite-prefix">Hi,<br clear="none">
There is a pending patch on
cfe-commits about this "[PATCH]
clang/Frontend/MultiplexConsumer.h".
With it you could reorder the
ASTConsumers in clang and get
yours before codegen.<br clear="none">
Vassil<br clear="none">
On 08/08/14 16:48, Bogdan Tabacaru
wrote:<br clear="none">
</div>
<blockquote type="cite"> </blockquote>
</div>
<div>
<div class="yiv8860464091yqt9700857600" id="yiv8860464091yqt84664">
<div style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">
<div class="yiv8860464091" style="">Hi everyone,</div>
<div class="yiv8860464091" style=""><br clear="none" class="yiv8860464091" style="">
</div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">I want to create
a plugin that makes some
changes on the parsed AST and
that directly compiles the
changes made on the AST. It is
important that I do not
generate a new file with the
changes on the AST.</div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">So, in other
words, I want to change the
AST in place, and then compile
it in the same run, using a
Clang Plugin.</div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br clear="none" class="yiv8860464091" style="">
</div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">I am using llvm
3.4.2.</div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br clear="none" class="yiv8860464091" style="">
</div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span class="yiv8860464091" style="font-size:12pt;">By
following the
RecursiveASTVisitor
example, </span>I have
written a clang plugin which
modifies the parsed AST.</div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br clear="none" class="yiv8860464091" style="">
</div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">I am using the
Rewriter class to ReplaceText
inside the buffer.</div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br clear="none" class="yiv8860464091" style="">
</div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;">I am also using
the -add-plugin <span class="yiv8860464091" style="font-size:12pt;">command</span><span class="yiv8860464091" style="font-size:12pt;"> </span><span class="yiv8860464091" style="background-color:transparent;">(instead
the "standard" -plugin
command) when calling the
plugin.</span></div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span class="yiv8860464091" style="background-color:transparent;"><br clear="none" class="yiv8860464091" style="">
</span></div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span class="yiv8860464091" style="background-color:transparent;">The
rewriting part works
excellently. However, when I
continue the compilation,
clang only compiles the
original file, instead of
the original file + changes.</span></div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span class="yiv8860464091" style="background-color:transparent;">Is
there a way to tell
clang/llvm to compile what I
have written in the AST
(using the Rewriter) without
creating an intermediate
file?</span></div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span class="yiv8860464091" style="background-color:transparent;"><br clear="none" class="yiv8860464091" style="">
</span></div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span class="yiv8860464091" style="background-color:transparent;">Thanks
a lot for your help,</span></div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><span class="yiv8860464091" style="background-color:transparent;">Bogdan</span></div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br clear="none" class="yiv8860464091" style="">
</div>
<div class="yiv8860464091" style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;"><br clear="none" class="yiv8860464091" style="">
</div>
</div>
</div>
<br clear="none">
<fieldset class="yiv8860464091mimeAttachmentHeader"></fieldset>
<br clear="none">
<pre>_______________________________________________
cfe-dev mailing list
<a rel="nofollow" shape="rect" class="yiv8860464091moz-txt-link-abbreviated" ymailto="mailto:cfe-dev@cs.uiuc.edu" target="_blank" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>
<a rel="nofollow" shape="rect" class="yiv8860464091moz-txt-link-freetext" target="_blank" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a>
</pre>
<br clear="none">
</div>
</div>
<br clear="none">
<br clear="none">
</div>
</div>
</div>
</div>
</div>
<br clear="none">
</div>
</div>
</div>
<br clear="none">
<br clear="none">
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br clear="none">
</div></div></div><br clear="none"><br clear="none"></div> </div> </div> </div></div> </div></div></div><br><br></div> </div> </div> </div> </div></body></html>