aboutsummaryrefslogtreecommitdiff
path: root/unittests/ASTMatchers
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2012-11-15 03:29:05 +0000
committerDaniel Jasper <djasper@google.com>2012-11-15 03:29:05 +0000
commit278057fd9f44684af832695cb01676c02a257b14 (patch)
tree823175118395643d3a208189604b7a29f989dac9 /unittests/ASTMatchers
parent5d23eeaaad325c5310591b0b8ae69298fecd21a0 (diff)
Do not use data recursion in ASTMatchFinder.
The matchers rely on the complete AST being traversed as shown by the new test cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168022 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ASTMatchers')
-rw-r--r--unittests/ASTMatchers/ASTMatchersTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp
index e15940aea4..6d8c00058b 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -947,6 +947,25 @@ TEST(Matcher, HasOperatorNameForOverloadedOperatorCall) {
OpCallLessLess));
}
+TEST(Matcher, NestedOverloadedOperatorCalls) {
+ EXPECT_TRUE(matchAndVerifyResultTrue(
+ "class Y { }; "
+ "Y& operator&&(Y& x, Y& y) { return x; }; "
+ "Y a; Y b; Y c; Y d = a && b && c;",
+ operatorCallExpr(hasOverloadedOperatorName("&&")).bind("x"),
+ new VerifyIdIsBoundTo<CXXOperatorCallExpr>("x", 2)));
+ EXPECT_TRUE(matches(
+ "class Y { }; "
+ "Y& operator&&(Y& x, Y& y) { return x; }; "
+ "Y a; Y b; Y c; Y d = a && b && c;",
+ operatorCallExpr(hasParent(operatorCallExpr()))));
+ EXPECT_TRUE(matches(
+ "class Y { }; "
+ "Y& operator&&(Y& x, Y& y) { return x; }; "
+ "Y a; Y b; Y c; Y d = a && b && c;",
+ operatorCallExpr(hasDescendant(operatorCallExpr()))));
+}
+
TEST(Matcher, ThisPointerType) {
StatementMatcher MethodOnY =
memberCallExpr(thisPointerType(recordDecl(hasName("Y"))));