<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hi,<br>
      TreeTransform is part of the "curiously recurring template
    pattern" used all around in clang.<br>
    You could define your own transformation that uses that pattern. It
    is very efficient because it<br>
    allows to have sort-of inheritance without having vtables.<br>
    Example code you can find in:<br>
    /lib/Sema/SemaTemplateInstantiate.cpp<br>
    /lib/Sema/SemaTemplateDeduction.cpp<br>
    /lib/Sema/SemaTemplate.cpp<br>
    However, TreeTransform is not public interface...<br>
    <br>
    There were a lot of changes in it recently and maybe my experience
    is old-dated but<br>
    I tried to use it once and I had hard time when I wanted to replace
    one node with 2 or more <br>
    nodes or when I tried to remove nodes. For 1:1 transformation I
    think is very good interface, though.<br>
    <br>
    Talking about optimizations: Have you consider the LLVM bitcode - it
    is SSA based and IMHO<br>
    is much more suitable for optimizations?<br>
    <br>
    Vassil<br>
    <br>
    On 12/01/2011 02:36 PM, eyasu getahun wrote:
    <blockquote
cite="mid:CAG_wWdqaA0V8uWd-KSsJdtTCZjtrTWRXuoB0LmGHhEziDRJvzw@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <font color="#330099"><font size="2"><font face="georgia,serif"><br>
            Hello Vasil,<br>
            <br>
            Thanks for your detail explanation. The main thing what I
            want to do is AST level optimization. But before
            implementing optimizations, I need to transform the
            resulting AST which is build by clang after parsing the
            given source code. That mean i want to transform this AST to
            another AST. Later it will be easy to implement
            optimizations on the new AST. When i read clang source
            files, I got TreeTransformation.h file. I thought that there
            is tree to tree transformation that is already implemented
            inside clang. But I couldn't get the implementation. Now am
            getting information from you guys that this file is just a
            facility or base for implementation other transformations.
            So, this is good information that I got from you guys. Now
            am going to do the transformation by my self and
            implementing optimizations later on. If there was
            implemented tree to tree transformation, i don't need to go
            implement tree transformation. <br>
            <br>
            Hope you got my idea. It is just my ideal design and didn't
            go further. I will start the tasks soon. Do you have any
            idea or suggestion how to go? Thanks again.<br>
          </font></font></font><br>
      <div class="gmail_quote">
        On Thu, Dec 1, 2011 at 9:01 PM, Vassil Vassilev <span dir="ltr"><<a
            moz-do-not-send="true"
            href="mailto:vasil.georgiev.vasilev@cern.ch">vasil.georgiev.vasilev@cern.ch</a>></span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          <div bgcolor="#ffffff" text="#000000"> Hi,<br>
              TreeTransform is the facility used to rebuild the
            templated nodes of the AST once<br>
            clang has the full type/value information (for example at
            instantiation time). It replaces<br>
            the nodes that are marked as of dependent type with their
            actual instantiation type and<br>
            performs the semantic checks with the new types.<br>
            <br>
              Maybe if you clarify a little bit more (and perhaps give
            examples) I can be more helpful.<br>
            In general TreeTransform is not meant to implement every
            possible tree-to-tree transformation.<br>
            <br>
            Nevertheless, it can be used as model how to build your own
            one. Right now I am not aware of<br>
            an interface that implements arbitrary tree-to-tree
            transformation. <br>
            However, there are couple of interfaces that you might find
            useful for that. You might want to<br>
            have a look at clang::ASTConsumer, clang::SemaConsumer and
            clang::RecursiveASTVisitor<br>
            <br>
            Depending on what is the exact idea of the transformation
            you could also use clang's <br>
            rewrite subsystem, which is pretty powerful, but it AFAIK it
            doesn't work on AST level. It is more<br>
            source-to-source transformation.<br>
            <br>
            Vassil
            <div>
              <div class="h5"><br>
                <br>
                On 11/30/2011 04:20 AM, eyasu getahun wrote: </div>
            </div>
            <blockquote type="cite">
              <div>
                <div class="h5"> <font color="#330099"><font size="2"><font
                        face="georgia,serif">Hello all,<br>
                        <br>
                         I have seen tree transformation in
                        clang(TreeTransform.h). This is to transform one
                        AST to another AST. But it is not clear for me
                        how they used this header file for the
                        transformation. I didn't see the function for
                        the transformation. Just they used this header
                        file for semantic template instantiation and
                        template deduction. Even there is no explicit
                        command line option for the transformation. Do
                        you guys think that the transformation is well
                        implemented and documented? please let me know
                        if you have any idea about the transformation
                        that they used in clang. Thanks in advance!<span><font
                            color="#888888"><br clear="all">
                          </font></span></font></font></font>
                  <div>
                    <div><img moz-do-not-send="true" src=""></div>
                  </div>
                  <br clear="all">
                  <br>
                  -- <br>
                  <b>With Best Regards,<br>
                    <br>
                    ===========================================<br>
                    Eyasu Getahun</b><br>
                  <br>
                  <br>
                </div>
              </div>
              <pre><fieldset></fieldset>
_______________________________________________
cfe-dev mailing list
<a moz-do-not-send="true" href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>
<a moz-do-not-send="true" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a>
</pre>
            </blockquote>
            <br>
          </div>
        </blockquote>
      </div>
      <br>
      <br clear="all">
      <br>
      -- <br>
      <b>With Best Regards,<br>
        <br>
        ===========================================<br>
        Eyasu Getahun</b><br>
      <br>
      1 Fusionopolis way, #08-10 Connexis North Tower<br>
      Singapore 138632, Singapore<br>
      Mobile: +393279239907<br>
      <b>===========================================<br>
      </b><br>
    </blockquote>
    <br>
  </body>
</html>