I’m looking for a AST matcher to match templated variables (ideally all declarations and usages of such variables) and have ran into a problem for certain references. For example, for the code:
template <class Type>
class Class
{
public:
void Func(Type var);
void Func1(const Type& var1);
void Func2(const Class<Type>& var2);
};
the match varDecl(hasType(templateTypeParmType())) matches only var.
I’d also like to match var1, but not var2.
the match varDecl(hasType(qualType(hasDescendant(qualType(templateTypeParmType()))))) matches var1, but unfortunately also matches var2.
What I’d like is to match variables with the base type Type, regardless of if it’s a pointer, reference, or if it’s const.
Could someone point me to a matcher that gives me var1 only (or ideally both var and var1)?
Many thanks!