Hi all,
I am trying to match type references of class A
in the following code:
template <typename T>
class A {};
template <typename T>
class Temp {
A<int> a;
A<T> at;
};
Hi all,
I am trying to match type references of class A
in the following code:
template <typename T>
class A {};
template <typename T>
class Temp {
A<int> a;
A<T> at;
};
Hi Eric,
A<T>
in class Temp
definition is a dependent name (see http://eel.is/c++draft/temp.dep) whereas in class Temp
specialization it is not (it is instantiated as A<int>
). In case of dependent names, clang will not offer you any additional details about the construct because semantics of such a construct may differ from one instantiation to another.
I had a very similar question few days ago (http://lists.llvm.org/pipermail/cfe-dev/2017-January/052376.html). Although I am not using AST matcher, but rather libclang directly, I did end up implementing heuristic method for extracting the details that I needed and which seems to be quite applicable in my target use-case. I am not sure about your use-case and how flexible AST matcher is but you might want to try to jump to the declaration of dependent-name node and then walk through it to get more details which you need.
Cheers,
Adi
Thank you for the explanation, Jusufadis! I am just trying to see if I can match a class template reference in a template declaration without going into ClassTemplateSpecializationDecl
so that I don’t need to worry about parameter substitution. But looks like I have to deal with the substitutions.