any complete example of a Rewriter that changes function call arguments?

I was attempting to extend this Rewriter example:

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.

Did you ever figure this out?

What handle did you use to get the name as getNameInfo() is not available?

I found the answer,

bool VisitCallExpr(CallExpr *CE){
_rewriter.ReplaceText(CE->getLocStart(), II->getName().size(),

For what it’s worth, you may want to check out and

Using RefactoringTool and Replacement makes it quite easy to rewrite things.