summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
diff options
context:
space:
mode:
authorSamuel Benzaquen <sbenza@google.com>2013-07-22 16:13:57 +0000
committerSamuel Benzaquen <sbenza@google.com>2013-07-22 16:13:57 +0000
commite0b2c8e478bea77088f8c1d2fdc2cbfa61ac59b1 (patch)
treebb232f96e9794e1481dc28465d853909c2197e34 /clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
parent75eff74803140f4e0d8713b7d55f8da70472b10b (diff)
downloadbcm5719-llvm-e0b2c8e478bea77088f8c1d2fdc2cbfa61ac59b1.tar.gz
bcm5719-llvm-e0b2c8e478bea77088f8c1d2fdc2cbfa61ac59b1.zip
Add support for overloaded matchers. ie different matcher function signatures with the same name.
Summary: Add support for overloaded matchers. This composes with other features, like supporting polymorphic matchers. Reviewers: klimek CC: cfe-commits, revane Differential Revision: http://llvm-reviews.chandlerc.com/D1188 llvm-svn: 186836
Diffstat (limited to 'clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
index 178a64a9fbf..e69017e531d 100644
--- a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -124,6 +124,30 @@ TEST_F(RegistryTest, ConstructWithMatcherArgs) {
EXPECT_FALSE(matches("void f(int x, int a);", HasParameter));
}
+TEST_F(RegistryTest, OverloadedMatchers) {
+ Matcher<Stmt> CallExpr0 = constructMatcher(
+ "callExpr",
+ constructMatcher("callee", constructMatcher("memberExpr",
+ constructMatcher("isArrow"))))
+ .getTypedMatcher<Stmt>();
+
+ Matcher<Stmt> CallExpr1 = constructMatcher(
+ "callExpr",
+ constructMatcher(
+ "callee",
+ constructMatcher("methodDecl",
+ constructMatcher("hasName", std::string("x")))))
+ .getTypedMatcher<Stmt>();
+
+ std::string Code = "class Y { public: void x(); }; void z() { Y y; y.x(); }";
+ EXPECT_FALSE(matches(Code, CallExpr0));
+ EXPECT_TRUE(matches(Code, CallExpr1));
+
+ Code = "class Z { public: void z() { this->z(); } };";
+ EXPECT_TRUE(matches(Code, CallExpr0));
+ EXPECT_FALSE(matches(Code, CallExpr1));
+}
+
TEST_F(RegistryTest, PolymorphicMatchers) {
const MatcherList IsDefinition = constructMatcher("isDefinition");
Matcher<Decl> Var =
OpenPOWER on IntegriCloud