(let me know if requests like this should go to the “users” list instead)
I’m playing around with the tooling facilities in clang, and have been using RemoveCStrCalls.cpp as an example.
Here is the problem I’m trying to solve:
I have a set of variables of a given type, I would like to refactor to use another type. To do this, I need to change the template arguments, and re-organize the arguments to the constructor.
Say we have: Foo<int, long> my_foo(1, 2);
We want: Bar<my_int, my_long> my_bar(my_int(1), my_long(2));
To find all the instances of Foo, I have written a matcher like this:
In my callback function I have managed to get access to the template arguments as I wanted to, and I got access to the instance name. So far so good…
But I can not figure out how I get access to the constructor arguments. I think I want to convert the VarDecl type to a CallExpr but I’m not sure that this is the right approach.
In my callback rutine I have the following code:
const VarDecl *decl = Result.Nodes.getNodeAs(“foo_instance”);
auto expr = decl->getInit();
And then I do not know how to continue…
A hint will be most appreciated.
Allan W. Nielsen