diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-07-14 14:05:02 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-07-14 14:05:02 +0000 |
commit | 09514492cc10922f2fada290ff8c2244879dc184 (patch) | |
tree | 8d82d294e6151926a2c56d5917fcefec770a8fb6 /clang/unittests/ASTMatchers/ASTMatchersTest.cpp | |
parent | 8e254166e1d23bc5a8430f83a23153782961b007 (diff) | |
download | bcm5719-llvm-09514492cc10922f2fada290ff8c2244879dc184.tar.gz bcm5719-llvm-09514492cc10922f2fada290ff8c2244879dc184.zip |
[ASTMatchers] Make hasOverloadedOperatorName also match freestanding overloads.
Freestanding overloads are represented as FunctionDecls in the AST, make
the matcher also match them.
Differential Revision: http://reviews.llvm.org/D4493
llvm-svn: 212940
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index e424acdaacd..f5cb130b1d7 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -1095,12 +1095,19 @@ TEST(Matcher, HasOperatorNameForOverloadedOperatorCall) { "bool operator&&(Y x, Y y) { return true; }; " "Y a; Y b; bool c = a && b;", OpCallLessLess)); + StatementMatcher OpStarCall = + operatorCallExpr(hasOverloadedOperatorName("*")); + EXPECT_TRUE(matches("class Y; int operator*(Y &); void f(Y &y) { *y; }", + OpStarCall)); DeclarationMatcher ClassWithOpStar = recordDecl(hasMethod(hasOverloadedOperatorName("*"))); EXPECT_TRUE(matches("class Y { int operator*(); };", ClassWithOpStar)); EXPECT_TRUE(notMatches("class Y { void myOperator(); };", ClassWithOpStar)) ; + DeclarationMatcher AnyOpStar = functionDecl(hasOverloadedOperatorName("*")); + EXPECT_TRUE(matches("class Y; int operator*(Y &);", AnyOpStar)); + EXPECT_TRUE(matches("class Y { int operator*(); };", AnyOpStar)); } TEST(Matcher, NestedOverloadedOperatorCalls) { |