I want to make a program that makes abstract names for all function,variable,namespace ... and replaces the current ones.To this purpose i have used the clang libtooling documentation as well as their AST visitor example. I have found other useful tutorials on the internet such as : This example of a tool that renames a function ; This example of how to write a matcher and replacer. My code has lots of finders like that in the first website :
virtual bool VisitVarDecl(VarDecl *func) {
errs() << func->getNameAsString()<<" ";
auto a = func->getType();
errs() << a.getAsString()<<"space";
//also tried this with no success
Twine a = Twine("works");
func->setName(a);
return true;
}
So the question is how do I replace all occurences of that name in the context of that name : for example a dumb replacer based on regex would replace global and local variable with the same name but using the namedDecl handle should get me only the one detected by the visitor?