aboutsummaryrefslogtreecommitdiff
path: root/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2012-07-17 07:39:27 +0000
committerDaniel Jasper <djasper@google.com>2012-07-17 07:39:27 +0000
commit20b802d186dfc5db9b4a9ce83e9f31fa5aa4efcc (patch)
treed0a22b3a202cc0b28f12bfff8b94588624a07f9d /unittests/ASTMatchers/ASTMatchersTest.cpp
parente4ed215ccf35d4407916cd0223de26f87ccbb055 (diff)
Make the isDerivedFrom matcher more generic.
It now accepts an arbitrary inner matcher but is fully backwards compatible. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160348 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--unittests/ASTMatchers/ASTMatchersTest.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp
index 597cf6fe4d..5791932b17 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -245,7 +245,7 @@ TEST(DeclarationMatcher, ClassIsDerived) {
variable(
hasName("z_char"),
hasInitializer(hasType(record(isDerivedFrom("Base1"),
- isDerivedFrom("Base2")))))));
+ isDerivedFrom("Base2")))))));
const char *RecursiveTemplateTwoParameters =
"class Base1 {}; class Base2 {};"
@@ -273,7 +273,17 @@ TEST(DeclarationMatcher, ClassIsDerived) {
variable(
hasName("z_char"),
hasInitializer(hasType(record(isDerivedFrom("Base1"),
- isDerivedFrom("Base2")))))));
+ isDerivedFrom("Base2")))))));
+ EXPECT_TRUE(matches(
+ "namespace ns { class X {}; class Y : public X {}; }",
+ record(isDerivedFrom("::ns::X"))));
+ EXPECT_TRUE(notMatches(
+ "class X {}; class Y : public X {};",
+ record(isDerivedFrom("::ns::X"))));
+
+ EXPECT_TRUE(matches(
+ "class X {}; class Y : public X {};",
+ record(isDerivedFrom(id("test", record(hasName("X")))))));
}
TEST(AllOf, AllOverloadsWork) {