[PATCH] D85536: [clang] Add a matcher for template template parameters.
Bruno Ricci via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 11 08:01:59 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4dccf115cc1: [clang] Add a matcher for template template parameters. (authored by riccibruno).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85536/new/
https://reviews.llvm.org/D85536
Files:
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===================================================================
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -408,6 +408,15 @@
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;
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===================================================================
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -514,6 +514,7 @@
REGISTER_MATCHER(templateArgumentCountIs);
REGISTER_MATCHER(templateName);
REGISTER_MATCHER(templateSpecializationType);
+ REGISTER_MATCHER(templateTemplateParmDecl);
REGISTER_MATCHER(templateTypeParmDecl);
REGISTER_MATCHER(templateTypeParmType);
REGISTER_MATCHER(throughUsingDecl);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===================================================================
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -740,6 +740,9 @@
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;
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -562,6 +562,18 @@
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.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85536.284733.patch
Type: text/x-patch
Size: 2830 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200811/c099e40d/attachment.bin>
More information about the cfe-commits
mailing list