diff options
author | Alexander Kornienko <alexfh@google.com> | 2016-03-22 11:03:03 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2016-03-22 11:03:03 +0000 |
commit | 976921d4b4911394fe0e88b047a01dad5e85c701 (patch) | |
tree | 4f6f70f1ef97ebc95a5d338b92331bc6c75d65bd /clang/unittests/ASTMatchers/ASTMatchersTest.cpp | |
parent | e5c095923dddb949f15f13645d69dc3c3d2342e7 (diff) | |
download | bcm5719-llvm-976921d4b4911394fe0e88b047a01dad5e85c701.tar.gz bcm5719-llvm-976921d4b4911394fe0e88b047a01dad5e85c701.zip |
[ASTMatchers] New matcher hasReturnValue added
Summary: A checker (will be uploaded after this patch) needs to check implicit casts. Existing generic matcher "has" ignores implicit casts and parenthesized expressions and no specific matcher for matching return value expression preexisted. The patch adds such a matcher (hasReturnValue).
Reviewers: klimek, sbenza
Subscribers: xazax.hun, klimek, cfe-commits
Patch by Ádám Balogh!
Differential Revision: http://reviews.llvm.org/D17986
llvm-svn: 264037
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index 63dc1a8b649..713ef5a84fe 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -5488,5 +5488,11 @@ TEST(NullPointerConstants, Basic) { EXPECT_TRUE(notMatches("int i = 0;", expr(nullPointerConstant()))); } +TEST(StatementMatcher, HasReturnValue) { + StatementMatcher RetVal = returnStmt(hasReturnValue(binaryOperator())); + EXPECT_TRUE(matches("int F() { int a, b; return a + b; }", RetVal)); + EXPECT_FALSE(matches("int F() { int a; return a; }", RetVal)); +} + } // end namespace ast_matchers } // end namespace clang |