I would like to know how to insert an argument to a function call using libclang? I have to following code that just prints the arguments:
class CASTVisitor : public RecursiveASTVisitor<CASTVisitor>
{
public:
CASTVisitor(Rewriter &R) : rewriter(R)
{
}
virtual bool VisitCallExpr(CallExpr *call)
{
for(int i = 0, j = call->getNumArgs(); i < j; ++ i)
{
errs() << "argType: " << call->getArg(i)->getType().getAsString() << "\n";
}
errs() << "** Added parameter to function call\n";
return true;
}
...
};
Edit:
And although I can read and set the arguments, I don't see any way to insert one at the beginning of the parmVarDcl() matcher.
The same goes with adding member variables to base classes and compound statements. It would seem you can change existing text but you cannot insert new object easily. Am I right?