summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2015-11-02 22:23:21 +0000
committerAlexander Kornienko <alexfh@google.com>2015-11-02 22:23:21 +0000
commit23e7a25830cc9d829a5df655b83260c862498bd3 (patch)
tree3d008018044b2e7995d75bb8e51992eba758f7a9 /unittests
parentaa52573f9181bd1f23284e98a7360c9dfec7a0d6 (diff)
downloadclang-23e7a25830cc9d829a5df655b83260c862498bd3.tar.gz
Make hasLHS and hasRHS matchers available for ArraySubscriptExpr
Summary: The hasBase and hasIndex don't tell anything about the position of the base and the index in the code, so we need hasLHS and hasRHS in some cases. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D14212 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251842 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ASTMatchers/ASTMatchersTest.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp
index 26ef2a7124..476a0be290 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2372,6 +2372,11 @@ TEST(MatchBinaryOperator, HasLHSAndHasRHS) {
EXPECT_TRUE(matches("void x() { true || false; }", OperatorTrueFalse));
EXPECT_TRUE(matches("void x() { true && false; }", OperatorTrueFalse));
EXPECT_TRUE(notMatches("void x() { false || true; }", OperatorTrueFalse));
+
+ StatementMatcher OperatorIntPointer = arraySubscriptExpr(
+ hasLHS(hasType(isInteger())), hasRHS(hasType(pointsTo(qualType()))));
+ EXPECT_TRUE(matches("void x() { 1[\"abc\"]; }", OperatorIntPointer));
+ EXPECT_TRUE(notMatches("void x() { \"abc\"[1]; }", OperatorIntPointer));
}
TEST(MatchBinaryOperator, HasEitherOperand) {