summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
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
commite39993eb8695fed534d52cb1b0662e649e536da9 (patch)
tree54d29302c20a30697a727047b61fa4452464da49 /clang/unittests/ASTMatchers/ASTMatchersTest.cpp
parent227a923140b446b281fde945d662ae16227d5f51 (diff)
downloadbcm5719-llvm-e39993eb8695fed534d52cb1b0662e649e536da9.tar.gz
bcm5719-llvm-e39993eb8695fed534d52cb1b0662e649e536da9.zip
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 llvm-svn: 251842
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index 26ef2a7124c..476a0be2904 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud