<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <font size="-1">Hi Dan,<br>
      <br>
      <font size="-1">In fact, I realized tha<font size="-1">t I <font
            size="-1">ha<font size="-1">d</font></font> not used
          TreeTransform for my com<font size="-1">pound statements
            modifications. <br>
            <br>
            However, as I am also interested in<font size="-1"> doing it
              this way, I tried it,<font size="-1"> and <font size="-1">encountered
                  the same problem as you. <font size="-1">My program
                    crashes in ActOnComp<font size="-1">oundStmt, at <font
                        size="-1">li<font size="-1">ne</font> 334 (<font
                          size="-1">revision 179053):<br>
                          <br>
                          <font size="-1">  if (NumElts != 0 &&
                            !CurrentInstantiationScope &&<br>
                                 
                            getCurCompoundScope().HasEmptyLoopBodies)<br>
                            <br>
                            <font size="-1"><font size="-1">i</font>n
                              the call to getCurCompondScope(). <font
                                size="-1">I</font>t seems t<font
                                size="-1">hat the FunctionScopes is <font
                                  size="-1">empty.<br>
                                  <br>
                                  I <font size="-1">temporarily solved
                                    the issue by adding:<br>
                                    <br>
                                    <font size="-1">   
                                      SemaRef.PushFunctionScope();<br>
                                          SemaRef.PushCompoundScope();<br>
                                      <br>
                                      <font size="-1">before the call t<font
                                          size="-1">o
                                          RebuildCompoundStmt in my
                                          sub-class of Tree<font
                                            size="-1">Transform.<font
                                              size="-1"> It seems to
                                              work, but I don't know if
                                              this is reliable for a
                                              more complex tool, and if
                                              th<font size="-1">e def<font
                                                  size="-1">ault
                                                  behavior</font> of
                                                TreeTransform for
                                                CompoundStmt is
                                                intentional.<br>
                                                <br>
                                                <font size="-1">If
                                                  somebody could comment
                                                  on this, I would also
                                                  appreciate.<br>
                                                  <br>
                                                  <font size="-1">Regards,<br>
                                                    <br>
                                                    <font size="-1">Beatrice.</font><br>
                                                  </font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font></font><br>
            </font></font></font></font></font>
    <div class="moz-cite-prefix">Le 03/04/2013 15:21, dan.sanduleac a
      écrit :<br>
    </div>
    <blockquote cite="mid:1364995305084-4031281.post@n3.nabble.com"
      type="cite">
      <pre wrap="">Hi Béatrice,

This is really helpful, but I got stuck somewhere.

I tried to create a similar setup, getting ahold of the Sema in my
ASTFrontendAction, and then trying to transform function bodies.
My VisitFunctionDecl runs TransformStmt (ultimately TransformCompoundStmt)
on the function's body, but it crashes because at this point
Sema::FunctionScopes is an empty vector, and the first thing
Sema::TransformCompoundStmt tries to do (via
Sema::ActOnStartOfCompoundStmt() -> Sema::PushCompoundScope()) is to push
the new CompoundScope onto the current FunctionScope .. which of course
doesn't exist since FunctionScopes is empty.

When exactly do you start traversing with the RecursiveASTVisitor? Is it
after semantic analysis, after the Parser had already populated the entire
AST, or somehow during?



--
View this message in context: <a class="moz-txt-link-freetext" href="http://clang-developers.42468.n3.nabble.com/Inserting-a-high-level-transformation-pass-that-uses-TreeTransform-tp4030773p4031281.html">http://clang-developers.42468.n3.nabble.com/Inserting-a-high-level-transformation-pass-that-uses-TreeTransform-tp4030773p4031281.html</a>
Sent from the Clang Developers mailing list archive at Nabble.com.

_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a>
</pre>
      <br>
      <pre class="moz-signature" cols="72">-- 
Béatrice Creusillet
SILKAN - <a class="moz-txt-link-abbreviated" href="http://www.silkan.com">www.silkan.com</a></pre>
    </blockquote>
  </body>
</html>