I'd like to distinguish T in contexts (1) and (2):

template<typename T>
class B<T, int> // 1
{
public:
static void hello() {}
T t; // 2
int t2;
};

Currently I implement VisitTemplateTypeParmTypeLoc in RecursiveASTVisitor, but it visits both 1 and 2, and I need to skip usages of T in contexts like (1).

I'd like to distinguish T in contexts (1) and (2):

template<typename T>
class B<T, int> // 1
{
public:
static void hello() {}
T t; // 2
int t2;
};

Currently I implement VisitTemplateTypeParmTypeLoc in RecursiveASTVisitor,
but it visits both 1 and 2, and I need to skip usages of T in contexts like
(1).

To capture the context, you can implement your own Traverse*() method that
calls to the original; then you know when a visitation was "inside" another
visitation.