<div dir="ltr">If you need a starting template for AST matchers, <a href="https://github.com/firolino/clang-tool">https://github.com/firolino/clang-tool</a> might be useful for you.</div><div class="gmail_extra"><br><div class="gmail_quote">2017-08-01 15:44 GMT+02:00 Marcel Schaible via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    At the moment I am using the ASTConsumer/ASTVisitor interface. But I
    am planing to switch to AST matchers asap.<br>
    After scratching my head for a while I found the solution for my
    problem. It was just a misunderstanding of the inheritance tree.<br>
    <br>
    Thanks for your help<span class="HOEnZb"><font color="#888888"><br>
    <br>
    Marcel</font></span><div><div class="h5"><br>
    <div class="m_6494952880152468731moz-cite-prefix">Am 01.08.2017 um 13:48 schrieb Manuel
      Klimek:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_quote">
          <div dir="ltr">On Tue, Aug 1, 2017 at 12:35 PM Marcel Schaible
            <<a href="mailto:marcel@schaible-consulting.de" target="_blank">marcel@schaible-consulting.de</a><wbr>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div text="#000000" bgcolor="#FFFFFF"> Manuel, thanks for
              your help. Of course I went already through a bunch of
              documentation including libtooling.<br>
              My tool is performing now the basic setup and can
              transform some simple cases.<br>
              <br>
              Do you know by chance how to retrieve the ASTContext from
              a ReturnStmt and a FuncDecl?<br>
            </div>
          </blockquote>
          <div><br>
          </div>
          <div>Generally, if you use AST matchers you'll have the
            ASTContext in the callback. What exactly is the problem
            you're running into?</div>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div text="#000000" bgcolor="#FFFFFF"><br>
              BTW: Your presentation at the EURO LLVM was very helpful!<br>
            </div>
          </blockquote>
          <div><br>
          </div>
          <div>Thanks! :)</div>
          <div> </div>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div text="#000000" bgcolor="#FFFFFF"> <br>
              Greetings from Munich</div>
            <div text="#000000" bgcolor="#FFFFFF"><br>
              <br>
              Marcel</div>
            <div text="#000000" bgcolor="#FFFFFF"><br>
              <br>
              <br>
              <br>
              <div class="m_6494952880152468731m_1533006104724532659moz-cite-prefix">Am
                01.08.2017 um 12:16 schrieb Manuel Klimek:<br>
              </div>
              <blockquote type="cite">
                <div dir="ltr">
                  <div>You'll probably want to take a look at
                    libtooling:</div>
                  <a href="https://clang.llvm.org/docs/LibTooling.html" target="_blank">https://clang.llvm.org/docs/<wbr>LibTooling.html</a><br>
                </div>
                <br>
                <div class="gmail_quote">
                  <div dir="ltr">On Fri, Jul 28, 2017 at 4:54 PM Marcel
                    Schaible via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>>
                    wrote:<br>
                  </div>
                  <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div text="#000000" bgcolor="#FFFFFF">
                      <p>Hi everyone,</p>
                      let's consider the example:
                      <p><font face="Courier New, Courier, monospace">int
                          foo(int p) {</font></p>
                      <p><font face="Courier New, Courier, monospace">   
                          if ( p)</font></p>
                      <p><font face="Courier New, Courier, monospace">      
                          /* code path#1 */<br>
                        </font></p>
                      <p><font face="Courier New, Courier, monospace">   
                              return 0;</font></p>
                      <p><font face="Courier New, Courier, monospace">    
                          else    {</font></p>
                      <p><font face="Courier New, Courier, monospace">       
                          /* code path#2 */<br>
                        </font></p>
                      <p><font face="Courier New, Courier, monospace">   
                              return 1;<br>
                        </font></p>
                      <p><font face="Courier New, Courier, monospace">   
                          }</font></p>
                      <p><font face="Courier New, Courier, monospace">}<br>
                        </font></p>
                      <p>1. What is the best solution to get the string
                        representation of the expression of a return
                        statement?</p>
                      <p>2. Because I want to perform some
                        transformation with return statements I have to
                        figure out if they are enclosed in a block? <br>
                      </p>
                      <p>The example above should be transformed in
                        something like<br>
                      </p>
                      <p><font face="Courier New, Courier, monospace">int
                          foo(int p) {</font></p>
                      <p><font face="Courier New, Courier, monospace">   
                          if ( p) { /* <---- */<br>
                        </font></p>
                      <p><font face="Courier New, Courier, monospace">      
                          /* do some processing ... */<br>
                        </font></p>
                      <p><font face="Courier New, Courier, monospace">     
                            return 0;</font></p>
                      <p><font face="Courier New, Courier, monospace">    
                          } /* <--- */<br>
                        </font></p>
                      <p><font face="Courier New, Courier, monospace">    
                          else    {</font></p>
                      <p><font face="Courier New, Courier, monospace">      
                          /* do some processing ... */<br>
                        </font></p>
                      <font face="Courier New, Courier, monospace">   
                            return 1;<br>
                      </font>
                      <p><font face="Courier New, Courier, monospace">   
                          }</font></p>
                      <p><font face="Courier New, Courier, monospace">}<br>
                        </font></p>
                      Any hints or pointers are welcome.<br>
                      <p>Thanks</p>
                      <p>Marcel<br>
                      </p>
                    </div>
                    ______________________________<wbr>_________________<br>
                    cfe-dev mailing list<br>
                    <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
                    <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
                  </blockquote>
                </div>
              </blockquote>
              <br>
            </div>
          </blockquote>
        </div>
      </div>
    </blockquote>
    <br>
  </div></div></div>

<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>