[cfe-dev] Source-to-source manipulations with Clang

Douglas Gregor dgregor at apple.com
Thu Jan 27 07:13:52 PST 2011


On Jan 27, 2011, at 4:52 AM, Andrey Tarasevich wrote:

> Hello!
> 
> Recently I started using Clang for the C-code parsing, but I have some problems with find information on how to do Source-to-source transformations. 
> 
> At the moment I can generate Abstract Syntax Tree and tree traversal trough the API, i.e. rewriting the ASTConsumer and DeclVisitor classes, but I don't know how to do the transformations of the AST and write it back to the source code. Could you please give me some feedback on how to do such manipulations? I didn't find anything useful in google, so I decided to write to mailing list. 

Check out RewriteObjC.cpp, which uses the (textual) Rewriter class to perform AST transformations.

	- Doug





More information about the cfe-dev mailing list