[cfe-dev] Source-to-source translation: modifying functions

Ilya Mirsky ilya.mirsky at gmail.com
Sun Aug 22 03:54:26 PDT 2010


Hi all,

I'm working on a Source-to-source translator, which should introduce various
modifications to the original source code.
I'm doing the modifications from an ASTConsumer, calling
clang/Rewrite/Rewriter methods, and using the different visitors
(clang/AST/*Visitor) to access all Decl/Stmt.
The problems I'm having:


   1. Changing function names: if I change the name with
   FunctionDecl::SetDeclName it doesn't reflect in RewriteBuffer. If I want to
   use the Rewriter::ReplaceText method I don't know how to determine the exact
   SourceLocation of the function's identifier.
   2. Retrieving params value in calls: CallExpr::getArg(i) gives me the Arg
   Expr, and I can easily get its type, but how can I get it's value? I don't
   need to evaluate the Expr, just get the corresponding string code.
   3. Modifying signatures(params list): I'm having difficulties with
   FucntionDecl::setParams (Kind of a custom defined type), and
   Rewriter::ReplaceText requires the exact source location of the params list,
   which I'm unable to determine.


Is it the right way to accomplish what I need, or am I totally wrong?
Any help will be appreciated.
Many thanks,
Ilya

-- 
Best Regards,
Ilya Mirsky
www.cs.bgu.ac.il/~mirskyil <http://www.cs.bgu.ac.il/%7Emirskyil>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100822/b05bf6ba/attachment.html>


More information about the cfe-dev mailing list