diff options
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r-- | unittests/ASTMatchers/ASTMatchersTest.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 6d8c00058b..3eddccc652 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -2777,6 +2777,22 @@ TEST(ForEachDescendant, BindsOneNode) { new VerifyIdIsBoundTo<FieldDecl>("x", 1))); } +TEST(ForEachDescendant, NestedForEachDescendant) { + DeclarationMatcher m = recordDecl( + isDefinition(), decl().bind("x"), hasName("C")); + EXPECT_TRUE(matchAndVerifyResultTrue( + "class A { class B { class C {}; }; };", + recordDecl(hasName("A"), anyOf(m, forEachDescendant(m))), + new VerifyIdIsBoundTo<Decl>("x", "C"))); + + // FIXME: This is not really a useful matcher, but the result is still + // surprising (currently binds "A"). + //EXPECT_TRUE(matchAndVerifyResultTrue( + // "class A { class B { class C {}; }; };", + // recordDecl(hasName("A"), allOf(hasDescendant(m), anyOf(m, anything()))), + // new VerifyIdIsBoundTo<Decl>("x", "C"))); +} + TEST(ForEachDescendant, BindsMultipleNodes) { EXPECT_TRUE(matchAndVerifyResultTrue( "class C { class D { int x; int y; }; " |