[cfe-dev] Rewriting AST through Clang's LibTooling APIs
Artem Dergachev via cfe-dev
cfe-dev at lists.llvm.org
Wed Jun 13 18:53:45 PDT 2018
Just to summarize:
- Yes, modifying AST is possible, albeit difficult to do correctly.
- No, squeezing the modified AST back into source code in order to
modify the source code is definitely not supported. Replacing text with
the help of the AST's source locations information is the intended way
of writing tools that modify source code with clang.
On 6/13/18 1:30 PM, Koustubha Bhat via cfe-dev wrote:
> Hi All,
>
> I am exploring the LibTooling APIs to parse and perform targeted modifications to the AST.
> I see that Rewriter interface allows to insert or replace text, however the writing remains in terms of text.
> May I know if rewriting the AST itself by means of inserting or modifying AST nodes, is supported?
>
> Thank you.
>
> Regards,
> Koustubha
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list