[cfe-dev] Future of AST transformation

Manuel Klimek klimek at google.com
Mon Jul 23 02:26:58 PDT 2012

On Fri, Jul 20, 2012 at 11:49 AM, Olaf Krzikalla
<Olaf.Krzikalla at tu-dresden.de> wrote:
> Am 19.07.2012 00:22, schrieb Richard Smith:
>> Take a look at lib/Sema/TreeTransform.h. Using that, it is certainly
>> possible to perform AST to AST transformations in a way which is
>> convenient and maintains the AST invariants.
> I'm aware of that means. However I still haven't figuered out how
> TreeTransform can be used for a task like "a+=b" -> "a=a+b". Maybe
> someone has an example. In clang TreeTransform is used for different tasks.
>> The usual approach for clang-based source-to-source transformation tools
>> is to use the AST to determine what changes should be made, then produce
>> a list of modifications to be made to the original source file. See
>> clang::Rewriter, clang::tooling::Replacement, and
>> clang::tooling::RefactoringTool for some components which make it easier
>> to build such tools.
> What Ronan said: I use the transformation for SIMD vectorization of
> loops. The resulting code is still readable but not any longer in a way
> suitable for maintenance. Mostly it is sent to a compiler straightforward.

I'm probably missing something, but my gut feeling would be that this
should be rather done as an llvm pass... Any specific reasons that
speak against this?


> I still think that an universal AST transformation framework would offer
> some great opportunities. I do it for years now and most of the time all
> went OK, esp. on statement level. All the hassle starts on expression
> level (and mostly due to ImplicitCastExpr).
> Best regards
> Olaf Krzikalla
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

More information about the cfe-dev mailing list