Getting SubstTemplateTypeParmType Template Info

Hi,

Given the below input to clang tooling, when I traverse ParameterMap’s type, I get that std::map is a template specialization, with two nested template specializations, std::basic_string. Therefore I can extract the information I’m looking for.
#include

using String = std::string;
using ParameterMap = std::map<String, String>;

If we take the indirection one step further with this input to clang tooling
#include

template <typename K, typename V> using Map = std::map<K, V>;
using String = std::string;
using ParameterMap = Map<String, String>;

ParameterMap someFunc() { return ParameterMap(); }

then String is now a SubstTemplateTypeParmType. If I desugar that, I get that String is a record rather than a template specialization, so I cannot get the template types of String. Is that intended? How can I get the template information for String in this case?

Thanks,
Justin

TemplateSpecializationType is a sugar type representing the fact that a
type was written in source as SomeTemplate<TemplateArgs...>. The
template arguments there should be the source template arguments, which
may differ from the true template arguments due to e.g. default arguments;
similarly, the template name there might be a template alias, and the true
type may not be a class type at all.

If you don’t particularly care about the spelling in source code and just
want to check if a type ultimately names a class template specialization,
you should getAs<RecordType>() and then dyn_cast the RecordDecl to
ClassTemplateSpecializationDecl.

John.