[cfe-dev] Getting macro values, and processing CallExpr with arguments of types from included headers

Ilya Mirsky ilya.mirsky at gmail.com
Thu Oct 7 07:15:49 PDT 2010


Hi all,

Posted similar questions 2 days ago, this time more detailed.

I'm working on a tool for src-2-src transformations.
One of the functions of this tool is replacing function calls in the code.
I'm having problems with this operation whenever one of the arguments of the
call is a macro, or of a type declared in an included header:

   1. To get the value of arguments I get it's SourceRange, and get the
   associated code using SourceManager::getCharacterData. That usually works,
   but when it's a macro I get an error: "terminate called after throwing an
   instance of 'std::length_error'  what():  basic_string::_S_create ".
   2. In order to replace function calls, I use StmtVisitor to find all
   CallExpr. The problem is when one of the arguments is of a type declared in
   an included header, this call, for some reason, is ignored and not visited.

Both this issues concern pre-processing, so I have a principle question-
when accessing the AST wiith ASTConsumer, is it after the pre-proccessing
phase?


Thanks in advance, any help will be greatly appreciated,
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/20101007/386591c2/attachment.html>


More information about the cfe-dev mailing list