<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi Bogdan,<br>
        After applying the attached patch, I can do:<br>
      <br>
      void MyPlugin::Initialize(ASTContext& Context) {<br>
       
      <meta http-equiv="content-type" content="text/html;
        charset=ISO-8859-1">
      // We need to reorder the consumers in the MultiplexConsumer.<br>
      MultiplexConsumer& multiplex<br>
      =
      static_cast<MultiplexConsumer&>(m_CI.getASTConsumer());<br>
      std::vector<ASTConsumer*>& consumers =
      multiplex.getConsumers();<br>
      ASTConsumer* lastConsumer = consumers.back();<br>
      consumers.pop_back();<br>
      consumers.insert(consumers.begin(), lastConsumer);<br>
      }<br>
      <br>
      This allows me to hook MyPlugin before clang's codegen.<br>
      <br>
      Vassil<br>
      On 09/08/14 21:24, Bogdan Tabacaru wrote:<br>
    </div>
    <blockquote
      cite="mid:1407612255.54210.YahooMailNeo@web120006.mail.ne1.yahoo.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <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>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>
          </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="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 face="Arial" size="2"> On Friday,
                  August 8, 2014 6:16 PM, Vassil Vassilev
                  <a class="moz-txt-link-rfc2396E" href="mailto:vvasilev@cern.ch"><vvasilev@cern.ch></a> wrote:<br>
                </font> </div>
              <br>
              <br>
              <div class="y_msg_container">
                <div id="yiv6792563898">
                  <div>
                    <div class="yiv6792563898moz-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="yiv6792563898yqt9700857600"
                      id="yiv6792563898yqt84664">
                      <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="yiv6792563898" style="">Hi everyone,</div>
                        <div class="yiv6792563898" style=""><br
                            class="yiv6792563898" style="" clear="none">
                        </div>
                        <div class="yiv6792563898" 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="yiv6792563898" 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="yiv6792563898" 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 class="yiv6792563898"
                            style="" clear="none">
                        </div>
                        <div class="yiv6792563898" 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="yiv6792563898" 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 class="yiv6792563898"
                            style="" clear="none">
                        </div>
                        <div class="yiv6792563898" 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="yiv6792563898"
                            style="font-size:12pt;">By following the
                            RecursiveASTVisitor example, </span>I have
                          written a clang plugin which modifies the
                          parsed AST.</div>
                        <div class="yiv6792563898" 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 class="yiv6792563898"
                            style="" clear="none">
                        </div>
                        <div class="yiv6792563898" 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="yiv6792563898" 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 class="yiv6792563898"
                            style="" clear="none">
                        </div>
                        <div class="yiv6792563898" 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="yiv6792563898"
                            style="font-size:12pt;">command</span><span
                            class="yiv6792563898"
                            style="font-size:12pt;"> </span><span
                            class="yiv6792563898"
                            style="background-color:transparent;">(instead
                            the "standard" -plugin command) when calling
                            the plugin.</span></div>
                        <div class="yiv6792563898" 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="yiv6792563898"
                            style="background-color:transparent;"><br
                              class="yiv6792563898" style=""
                              clear="none">
                          </span></div>
                        <div class="yiv6792563898" 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="yiv6792563898"
                            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="yiv6792563898" 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="yiv6792563898"
                            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="yiv6792563898" 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="yiv6792563898"
                            style="background-color:transparent;"><br
                              class="yiv6792563898" style=""
                              clear="none">
                          </span></div>
                        <div class="yiv6792563898" 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="yiv6792563898"
                            style="background-color:transparent;">Thanks
                            a lot for your help,</span></div>
                        <div class="yiv6792563898" 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="yiv6792563898"
                            style="background-color:transparent;">Bogdan</span></div>
                        <div class="yiv6792563898" 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 class="yiv6792563898"
                            style="" clear="none">
                        </div>
                        <div class="yiv6792563898" 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 class="yiv6792563898"
                            style="" clear="none">
                        </div>
                      </div>
                    </div>
                    <br clear="none">
                    <fieldset class="yiv6792563898mimeAttachmentHeader"></fieldset>
                    <br clear="none">
                    <pre>_______________________________________________
cfe-dev mailing list
<a moz-do-not-send="true" rel="nofollow" shape="rect" class="yiv6792563898moz-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 moz-do-not-send="true" rel="nofollow" shape="rect" class="yiv6792563898moz-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>
                <br>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>