libclang nested template FIELD_DECL

I’m walking through the cursor in a translation unit and the cursor for “test” in the following code is of kind FIELD_DECL and has four children:
TEMPLATE_REF → A
TEMPLATE_REF → TT2
TYPE_REF → B
TYPE_REF → B2

Since they are all children of “test”, how can I determine whether B2 is an argument in the instantiation of the template TT2 or A? I tried calling clang_getCursorReferenceNameRange with CXNameRange_WantTemplateArgs on each of these 5 cursor, but in every case the returned range would equal the result of clang_getCursorExtent so that didn’t .

Any ideas?

Thanks

template <typename T, typename B=int>
class A
{
};

template <typename T2, typename T3=int>
class TT2
{
};

class B
{
};

class B2
{
};

class C
{
A< TT2<B, B2> > test;
};

Resending since I’ve seen no reply yet.

Same thing with the cursors for a typedef:

typedef A< TT2<B, B2> > ZZ;

How do I figure out whether B2 belongs to A or TT2 if both the templates classes A and TT2 can take a variable amount of template parameters, and A, TT2, B, B2 are all children of ZZ?

Thanks.

/f