I'm trying to get the RHS template type of a TypeAliasDecl.
Example:
using AliasOfType = AliasedType; // AliasedType itself is a template
I can retrieve AliasOfType
in the AST using clang::ast_matchers::typeAliasDecl
. I want to retrieve AliasedType
with a clang::ast_matchers::
.
The AST dump of clang::ast_matchers::typeAliasDecl
looks like:
TypeAliasDecl 0x4fe22cf8 AliasOfType
-SubstTemplateTypeParmType 0x4fe22cc0
|-TemplateTypeParmType 0x4fe1a840 `AliasedType` dependent depth 0 index 0
| `-TemplateTypeParm 0x4fe1a7f8 'AliasedType'
So intuitively, I'd want to match for TemplateTypeParm
which has my previous match as an ancestor. However, I haven't found an ast_matcher
that does that. There's clang::ast_matchers::templateTypeParmType
, but it gives errors if I try to put anything as a narrowing parameter like:
templateTypeParmType(hasName("AliasedType"))
The error I get when I try that is:
clang/ASTMatchers/ASTMatchersInternal.h:1347:13: error: ‘clang::ast_matchers::internal::Matcher< <template-parameter-1-1> >::Matcher(const clang::ast_matchers::internal::DynTypedMatcher&) [with T = clang::TemplateTypeParmType]’ is private within this context
return {Matcher<T>(std::get<Is>(Params))...};
Aucun commentaire:
Enregistrer un commentaire