Add partial support for the hasDeclaration() matcher in the dynamic layer.
Summary:
Add partial support for the hasDeclaration() matcher in the dynamic layer.
This matcher has some special logic to allow any type that has a getDecl() method. We do not support this right now.
Reviewers: klimek
CC: cfe-commits, revane
Differential Revision: http://llvm-reviews.chandlerc.com/D1889
llvm-svn: 195013
diff --git a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
index 9a24c80..e716484 100644
--- a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -179,6 +179,19 @@
EXPECT_FALSE(matches("int Foo;", RecordDecl));
EXPECT_TRUE(matches("class Foo {};", RecordDecl));
EXPECT_FALSE(matches("void Foo(){};", RecordDecl));
+
+ Matcher<Stmt> ConstructExpr = constructMatcher(
+ "constructExpr",
+ constructMatcher(
+ "hasDeclaration",
+ constructMatcher(
+ "methodDecl",
+ constructMatcher(
+ "ofClass", constructMatcher("hasName", std::string("Foo"))))))
+ .getTypedMatcher<Stmt>();
+ EXPECT_FALSE(matches("class Foo { public: Foo(); };", ConstructExpr));
+ EXPECT_TRUE(
+ matches("class Foo { public: Foo(); }; Foo foo = Foo();", ConstructExpr));
}
TEST_F(RegistryTest, TemplateArgument) {