diff options
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index d84e6a6ef9d..cf77f2f4dd5 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -1530,6 +1530,19 @@ TEST(Matcher, MatchesDeclarationReferenceTemplateArgument) { "A<int> a;", classTemplateSpecializationDecl(hasAnyTemplateArgument( refersToDeclaration(decl()))))); + + EXPECT_TRUE(matches( + "struct B { int next; };" + "template<int(B::*next_ptr)> struct A {};" + "A<&B::next> a;", + templateSpecializationType(hasAnyTemplateArgument(isExpr( + hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))))); + + EXPECT_TRUE(notMatches( + "template <typename T> struct A {};" + "A<int> a;", + templateSpecializationType(hasAnyTemplateArgument( + refersToDeclaration(decl()))))); } TEST(Matcher, MatchesSpecificArgument) { @@ -1543,6 +1556,17 @@ TEST(Matcher, MatchesSpecificArgument) { "A<int, bool> a;", classTemplateSpecializationDecl(hasTemplateArgument( 1, refersToType(asString("int")))))); + + EXPECT_TRUE(matches( + "template<typename T, typename U> class A {};" + "A<bool, int> a;", + templateSpecializationType(hasTemplateArgument( + 1, refersToType(asString("int")))))); + EXPECT_TRUE(notMatches( + "template<typename T, typename U> class A {};" + "A<int, bool> a;", + templateSpecializationType(hasTemplateArgument( + 1, refersToType(asString("int")))))); } TEST(Matcher, MatchesAccessSpecDecls) { |