<div dir="ltr">Hi,<br><br>(let me know if requests like this should go to the "users" list instead)<br><br>I'm playing around with the tooling facilities in clang, and have been using RemoveCStrCalls.cpp as an example.<br>
<br>Here is the problem I'm trying to solve:<br><br>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.<br>
<br>Example:<br><br>Say we have: Foo<int, long> my_foo(1, 2);<br><br>We want: Bar<my_int, my_long> my_bar(my_int(1), my_long(2));<br><br>To find all the instances of Foo, I have written a matcher like this:<br>
<br>  Finder.addMatcher(<br>      id("foo_instance",<br>         varDecl(hasType(recordDecl(hasName("::Foo"))))),<br>      &Callback);<br><br>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...<br>
<br>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.<br><br>In my callback rutine I have the following code:<br>
<br>const VarDecl *decl = Result.Nodes.getNodeAs<VarDecl>("foo_instance");<br>auto expr = decl->getInit();<br><br>And then I do not know how to continue...<br><br>A hint will be most appreciated.<br><br>
Best regards<br>Allan W. Nielsen<br></div>