Parser/Registry argument enhancements.
Summary:
Parser/Registry argument enhancements.
- 2 argument support.
- unsigned values support.
Reviewers: klimek
CC: cfe-commits, revane
Differential Revision: http://llvm-reviews.chandlerc.com/D915
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183231 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
index 64af120..1055233 100644
--- a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -63,6 +63,10 @@
constructMatcher("hasName", std::string("X"), NULL));
EXPECT_TRUE(matchesDynamic("class X {};", *Value));
EXPECT_FALSE(matchesDynamic("int x;", *Value));
+
+ Value.reset(constructMatcher("parameterCountIs", 2, NULL));
+ EXPECT_TRUE(matchesDynamic("void foo(int,int);", *Value));
+ EXPECT_FALSE(matchesDynamic("void foo(int);", *Value));
}
TEST(RegistryTest, ConstructWithMatcherArgs) {
@@ -82,6 +86,11 @@
code = "int y(); int i = y();";
EXPECT_TRUE(matchesDynamic(code, *HasInitializerSimple));
EXPECT_TRUE(matchesDynamic(code, *HasInitializerComplex));
+
+ OwningPtr<DynTypedMatcher> HasParameter(
+ constructMatcher("hasParameter", 1, hasName("x"), NULL));
+ EXPECT_TRUE(matchesDynamic("void f(int a, int x);", *HasParameter));
+ EXPECT_FALSE(matchesDynamic("void f(int x, int a);", *HasParameter));
}
TEST(RegistryTest, Errors) {