I am new to clang AST. I am trying to write a program which rewrites all locations in a TU where template alias are used.
say, given
-
template<class T,class U = T>
-
class class_1{};
-
template
-
using alias1 = class_1;
-
template<class T,class U>
-
using alias2 = class_1<T,U>;
-
template<class X,class Y = alias1 >
-
void foo(…)
-
{
-
alias2<int,X> x = …;
-
}
I am interested to transform all references to template alias to something like typename alias1::type, typename alias2<int,X>::type x = … etc, and may be optionally remove the ‘typename’ part if the resulting type is not dependent.
I am using C++ API with RAV, and presently can get all template alias decl using
Visit/Traverse TypeAliasTemplateDecl, but has no idea how to get all references to them, such as at line 8 & 11 , irrespective to their name.
Any help will be appreciated.
Thank you.