[cfe-dev] Tree transformation in clang

eyasu getahun eya.get at gmail.com
Thu Dec 1 05:36:38 PST 2011


Hello Vasil,

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.

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.

On Thu, Dec 1, 2011 at 9:01 PM, Vassil Vassilev <
vasil.georgiev.vasilev at cern.ch> wrote:

> **
> Hi,
>   TreeTransform is the facility used to rebuild the templated nodes of the
> AST once
> clang has the full type/value information (for example at instantiation
> time). It replaces
> the nodes that are marked as of dependent type with their actual
> instantiation type and
> performs the semantic checks with the new types.
>
>   Maybe if you clarify a little bit more (and perhaps give examples) I can
> be more helpful.
> In general TreeTransform is not meant to implement every possible
> tree-to-tree transformation.
>
> Nevertheless, it can be used as model how to build your own one. Right now
> I am not aware of
> an interface that implements arbitrary tree-to-tree transformation.
> However, there are couple of interfaces that you might find useful for
> that. You might want to
> have a look at clang::ASTConsumer, clang::SemaConsumer and
> clang::RecursiveASTVisitor
>
> Depending on what is the exact idea of the transformation you could also
> use clang's
> rewrite subsystem, which is pretty powerful, but it AFAIK it doesn't work
> on AST level. It is more
> source-to-source transformation.
>
> Vassil
>
>
> On 11/30/2011 04:20 AM, eyasu getahun wrote:
>
> Hello all,
>
>  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!
>
>
> --
> *With Best Regards,
>
> ===========================================
> Eyasu Getahun*
>
>
>
> _______________________________________________
> cfe-dev mailing listcfe-dev at cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
>


-- 
*With Best Regards,

===========================================
Eyasu Getahun*

1 Fusionopolis way, #08-10 Connexis North Tower
Singapore 138632, Singapore
Mobile: +393279239907
*===========================================
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111201/71fff7cb/attachment.html>


More information about the cfe-dev mailing list