[cfe-dev] RE : AST Transformation

Konstantin Tokarev annulen at yandex.ru
Thu Mar 31 08:10:09 PDT 2011



31.03.2011, 18:59, "Nico Weber" <thakis at chromium.org>:
> 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.

Did you mean "it's impossible to transform AST" or just "it's impossible to hook in
before CodeGen"?

-- 
Regards,
Konstantin



More information about the cfe-dev mailing list