diff options
Diffstat (limited to 'clang/unittests/ASTMatchers')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 8 | ||||
-rw-r--r-- | clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index 1e5401d9bf3..d7f5b722df3 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -3667,6 +3667,14 @@ TEST(ExceptionHandling, SimpleCases) { varDecl(isExceptionVariable()))); } +TEST(ParenExpression, SimpleCases) { + EXPECT_TRUE(matches("int i = (3);", parenExpr())); + EXPECT_TRUE(matches("int i = (3 + 7);", parenExpr())); + EXPECT_TRUE(notMatches("int i = 3;", parenExpr())); + EXPECT_TRUE(notMatches("int foo() { return 1; }; int a = foo();", + parenExpr())); +} + TEST(HasConditionVariableStatement, DoesNotMatchCondition) { EXPECT_TRUE(notMatches( "void x() { if(true) {} }", diff --git a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp index 8e97566f692..a1b6a93456d 100644 --- a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp +++ b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp @@ -506,6 +506,12 @@ TEST_F(RegistryTest, HasArgs) { EXPECT_FALSE(matches("struct X {};", Value)); } +TEST_F(RegistryTest, ParenExpr) { + Matcher<Stmt> Value = constructMatcher("parenExpr").getTypedMatcher<Stmt>(); + EXPECT_TRUE(matches("int i = (1);", Value)); + EXPECT_FALSE(matches("int i = 1;", Value)); +} + } // end anonymous namespace } // end namespace dynamic } // end namespace ast_matchers |