[cfe-dev] Tree transformation in clang

Vassil Vassilev vasil.georgiev.vasilev at cern.ch
Thu Dec 1 05:01:30 PST 2011


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 list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111201/22dda16a/attachment.html>


More information about the cfe-dev mailing list