[cfe-dev] any complete example of a Rewriter that changes function call arguments?

Peeter Joot peeter.joot at gmail.com
Wed Dec 19 10:46:33 PST 2012


I was attempting to extend this Rewriter example:

http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang/

to transform function or macro calls from one to another.  Example

foo( a, b ) -> bar ( b )

Using a VisitCallExpr() I can get as far as finding the name of the
function, seeing if it's foo, and finding all the args, but it's not
obvious to me how to hook this into the rewriter, replacing args and
changing the function name.

Are there any full examples available for this sort of task?   Since this
is probably the most obvious application of Rewriter and ASTvisitor, I'm
sure this has been done a bunch of times.

-- 
Peeter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121219/37586cc8/attachment.html>


More information about the cfe-dev mailing list