summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 55c53e66ecd..3e27948db78 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1623,6 +1623,14 @@ TEST(IsTemplateInstantiation, MatchesExplicitClassTemplateInstantiation) {
"template class X<A>;",
cxxRecordDecl(isTemplateInstantiation(), hasDescendant(
fieldDecl(hasType(recordDecl(hasName("A"))))))));
+
+ // Make sure that we match the instantiation instead of the template
+ // definition by checking whether the member function is present.
+ EXPECT_TRUE(
+ matches("template <typename T> class X { void f() { T t; } };"
+ "extern template class X<int>;",
+ cxxRecordDecl(isTemplateInstantiation(),
+ unless(hasDescendant(varDecl(hasName("t")))))));
}
TEST(IsTemplateInstantiation,
OpenPOWER on IntegriCloud