summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2013-11-07 22:30:32 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2013-11-07 22:30:32 +0000
commit2b94713053aef3ca42e4e555ed6e04e41215762d (patch)
treeb6463e79921c5f5d26403cd6098ed98adfd3ee45 /clang/unittests/ASTMatchers/ASTMatchersTest.cpp
parentd3d140da3679d1b673b7edd2e4a27431fda98a89 (diff)
downloadbcm5719-llvm-2b94713053aef3ca42e4e555ed6e04e41215762d.tar.gz
bcm5719-llvm-2b94713053aef3ca42e4e555ed6e04e41215762d.zip
Re-introduce MatchFinder::addDynamicMatcher.
Differential Revision: http://llvm-reviews.chandlerc.com/D2114 llvm-svn: 194222
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index a848d55f989..5649ad897e8 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -40,6 +40,18 @@ TEST(IsDerivedFromDeathTest, DiesOnEmptyBaseName) {
}
#endif
+TEST(Finder, DynamicOnlyAcceptsSomeMatchers) {
+ MatchFinder Finder;
+ EXPECT_TRUE(Finder.addDynamicMatcher(decl(), NULL));
+ EXPECT_TRUE(Finder.addDynamicMatcher(callExpr(), NULL));
+ EXPECT_TRUE(Finder.addDynamicMatcher(constantArrayType(hasSize(42)), NULL));
+
+ // Do not accept non-toplevel matchers.
+ EXPECT_FALSE(Finder.addDynamicMatcher(isArrow(), NULL));
+ EXPECT_FALSE(Finder.addDynamicMatcher(hasSize(2), NULL));
+ EXPECT_FALSE(Finder.addDynamicMatcher(hasName("x"), NULL));
+}
+
TEST(Decl, MatchesDeclarations) {
EXPECT_TRUE(notMatches("", decl(usingDecl())));
EXPECT_TRUE(matches("namespace x { class X {}; } using x::X;",
@@ -651,11 +663,18 @@ public:
: Id(Id), ExpectedCount(ExpectedCount), Count(0),
ExpectedName(ExpectedName) {}
- ~VerifyIdIsBoundTo() {
+ void onEndOfTranslationUnit() LLVM_OVERRIDE {
if (ExpectedCount != -1)
EXPECT_EQ(ExpectedCount, Count);
if (!ExpectedName.empty())
EXPECT_EQ(ExpectedName, Name);
+ Count = 0;
+ Name.clear();
+ }
+
+ ~VerifyIdIsBoundTo() {
+ EXPECT_EQ(0, Count);
+ EXPECT_EQ("", Name);
}
virtual bool run(const BoundNodes *Nodes) {
OpenPOWER on IntegriCloud