[clang] Add a matcher for template template parameters.
There are already matchers for type template parameters and non-type template parameters, but somehow no matcher exists for template template parameters and I need it to write unit tests. Differential Revision: https://reviews.llvm.org/D85536 Reviewed By: aaron.ballman
This commit is contained in:
parent
e2f3240472
commit
f4dccf115c
@ -562,6 +562,18 @@ extern const internal::VariadicDynCastAllOfMatcher<Decl,
|
||||
extern const internal::VariadicDynCastAllOfMatcher<Decl, TemplateTypeParmDecl>
|
||||
templateTypeParmDecl;
|
||||
|
||||
/// Matches template template parameter declarations.
|
||||
///
|
||||
/// Given
|
||||
/// \code
|
||||
/// template <template <typename> class Z, int N> struct C {};
|
||||
/// \endcode
|
||||
/// templateTypeParmDecl()
|
||||
/// matches 'Z', but not 'N'.
|
||||
extern const internal::VariadicDynCastAllOfMatcher<Decl,
|
||||
TemplateTemplateParmDecl>
|
||||
templateTemplateParmDecl;
|
||||
|
||||
/// Matches public C++ declarations and C++ base specifers that specify public
|
||||
/// inheritance.
|
||||
///
|
||||
|
||||
@ -740,6 +740,9 @@ const internal::VariadicDynCastAllOfMatcher<Decl, NonTypeTemplateParmDecl>
|
||||
nonTypeTemplateParmDecl;
|
||||
const internal::VariadicDynCastAllOfMatcher<Decl, TemplateTypeParmDecl>
|
||||
templateTypeParmDecl;
|
||||
const internal::VariadicDynCastAllOfMatcher<Decl, TemplateTemplateParmDecl>
|
||||
templateTemplateParmDecl;
|
||||
|
||||
const internal::VariadicAllOfMatcher<QualType> qualType;
|
||||
const internal::VariadicAllOfMatcher<Type> type;
|
||||
const internal::VariadicAllOfMatcher<TypeLoc> typeLoc;
|
||||
|
||||
@ -514,6 +514,7 @@ RegistryMaps::RegistryMaps() {
|
||||
REGISTER_MATCHER(templateArgumentCountIs);
|
||||
REGISTER_MATCHER(templateName);
|
||||
REGISTER_MATCHER(templateSpecializationType);
|
||||
REGISTER_MATCHER(templateTemplateParmDecl);
|
||||
REGISTER_MATCHER(templateTypeParmDecl);
|
||||
REGISTER_MATCHER(templateTypeParmType);
|
||||
REGISTER_MATCHER(throughUsingDecl);
|
||||
|
||||
@ -408,6 +408,15 @@ TEST_P(ASTMatchersTest, TemplateTypeParmDecl) {
|
||||
EXPECT_TRUE(notMatches("template <int N> void f();", templateTypeParmDecl()));
|
||||
}
|
||||
|
||||
TEST_P(ASTMatchersTest, TemplateTemplateParmDecl) {
|
||||
if (!GetParam().isCXX())
|
||||
return;
|
||||
EXPECT_TRUE(matches("template <template <typename> class Z> void f();",
|
||||
templateTemplateParmDecl(hasName("Z"))));
|
||||
EXPECT_TRUE(notMatches("template <typename, int> void f();",
|
||||
templateTemplateParmDecl()));
|
||||
}
|
||||
|
||||
TEST_P(ASTMatchersTest, UserDefinedLiteral) {
|
||||
if (!GetParam().isCXX11OrLater()) {
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user