diff options
Diffstat (limited to 'clang/unittests/ASTMatchers')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index 8df0274504e..b6d21e69975 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -2967,6 +2967,12 @@ TEST(SwitchCase, MatchesEachCase) { new VerifyIdIsBoundTo<CaseStmt>("x", 3))); } +TEST(ForEachConstructorInitializer, MatchesInitializers) { + EXPECT_TRUE(matches( + "struct X { X() : i(42), j(42) {} int i, j; };", + constructorDecl(forEachConstructorInitializer(ctorInitializer())))); +} + TEST(ExceptionHandling, SimpleCases) { EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", catchStmt())); EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", tryStmt())); @@ -3157,6 +3163,11 @@ TEST(LoopingMatchers, DoNotOverwritePreviousMatchResultOnFailure) { "class A {};", recordDecl(hasName("::A"), decl().bind("x"), unless(hasName("fooble"))), new VerifyIdIsBoundTo<Decl>("x", 1))); + EXPECT_TRUE(matchAndVerifyResultTrue( + "class A { A() : s(), i(42) {} const char *s; int i; };", + constructorDecl(hasName("::A::A"), decl().bind("x"), + forEachConstructorInitializer(forField(hasName("i")))), + new VerifyIdIsBoundTo<Decl>("x", 1))); } TEST(ForEachDescendant, BindsCorrectNodes) { |