[cfe-dev] RE : AST Transformation

Nico Weber thakis at chromium.org
Thu Mar 31 07:59:21 PDT 2011


On Thu, Mar 31, 2011 at 1:51 AM, Konstantin Tokarev <annulen at yandex.ru> wrote:
>
>
> 31.03.2011, 11:24, "Ruch Grégory" <gregory.ruch at heig-vd.ch>:
>> But the question is more technical about Clang. Can we just implement AST transformation plugin and let the normal execution of Clang to build the executable ? I've read that pretty-print do not garantee to get reparsable code, therefore I throught that it will be better to build directly the executable.
>
> I'd like to join this part of question (but not in obfuscation aspect).
>
> AFAIU, plugins like PrintFunctionNames can only replace Clang AST
> transformation, but not add one to compilation process.

You can use -add-plugin to run plugins in addition to codegen, but the
plugins will run _after_ codegen, because the AST is currently
designed to be immutable.

> More specifically, I'm trying to create C++ frontend explicitly supporting
> features of Qt Framework. Goal is to provide additional compile-time
> diagnostics and optimizations. To achieve it, I'd like to interact with AST
> when it is constructed (via custom ASTConsumer or maybe PPCallbacks,
> or both), then perform some transformations of this AST, and return it back
> into compilation process.

That's currently not possible.

>
> It would be great if it could be done in a plugin, because otherwise I'm afraid
> that I'll need to fork Driver and introduce substantial modifications to it's code.
>
> Any suggestions?
>
> --
> Regards,
> Konstantin
> _______________________________________________
> 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