[cfe-dev] AST transformations
vasil.georgiev.vasilev at cern.ch
Thu Mar 10 14:05:11 CST 2011
On 10.3.2011 г. 22:48, Reid Kleckner wrote:
> On Thu, Mar 10, 2011 at 2:43 PM, Vassil Vassilev
> <vasil.georgiev.vasilev at cern.ch> wrote:
>> On 10.3.2011 г. 18:07, Reid Kleckner wrote:
>>> True. I've been assured that mutating the AST is very difficult to do
>>> correctly, but I don't fully understand why. Perhaps it would be a
>>> good idea to write up an FAQ explaining why clang doesn't support it,
>>> with an example of why a simple local modification can break other
>>> parts of the AST (ie switching the cmp condition).
>>>> RewriteObjC class uses ASTConsumer; however, looking at the source
>>>> it's not immediately clear to me whether it is transforming the AST or
>>>> just inserting extra declarations/statements/etc. at the source level.
>>> The recommended approach for transforming the program source is to
>>> analyze the AST and use the source locations in the AST to make
>>> textual, source-level edits.
>> This part I didn't understand. You mean finding the source location of
>> the AST nodes, inserting and reparsing?
> I don't know much about the objc rewriter, but the way that fixits
> work is they emit a diagnostic that has a symbolic textual operation
> on it, something like insert, replace, or delete text at a given
> source range. There is no reparsing.
Hm... looks interesting. I will have a look. Thanks!
More information about the cfe-dev