Add TemplateArgument related matchers to the registry.

Summary:
Continue adding more matchers to the dynamic registry.
This time, we add TemplateArgument matchers.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1166

llvm-svn: 186514
This commit is contained in:
Samuel Benzaquen 2013-07-17 15:11:30 +00:00
parent 3122deb65c
commit 21b3da0f93
2 changed files with 16 additions and 4 deletions

View File

@ -56,10 +56,6 @@ void RegistryMaps::registerMatcher(StringRef MatcherName,
RegistryMaps::RegistryMaps() {
// TODO: Here is the list of the missing matchers, grouped by reason.
//
// Need DynTypedNode fixes:
// hasAnyTemplateArgument
// hasTemplateArgument
//
// Need Variant/Parser fixes:
// ofKind
//
@ -155,6 +151,7 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(hasAnyConstructorInitializer);
REGISTER_MATCHER(hasAnyParameter);
REGISTER_MATCHER(hasAnySubstatement);
REGISTER_MATCHER(hasAnyTemplateArgument);
REGISTER_MATCHER(hasAnyUsingShadowDecl);
REGISTER_MATCHER(hasArgument);
REGISTER_MATCHER(hasArgumentOfType);
@ -189,6 +186,7 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(hasSizeExpr);
REGISTER_MATCHER(hasSourceExpression);
REGISTER_MATCHER(hasTargetDecl);
REGISTER_MATCHER(hasTemplateArgument);
REGISTER_MATCHER(hasTrueExpression);
REGISTER_MATCHER(hasUnaryOperand);
REGISTER_MATCHER(hasValueType);

View File

@ -157,6 +157,20 @@ TEST_F(RegistryTest, PolymorphicMatchers) {
#endif
}
TEST_F(RegistryTest, TemplateArgument) {
Matcher<Decl> HasTemplateArgument = constructMatcher(
"classTemplateSpecializationDecl",
constructMatcher(
"hasAnyTemplateArgument",
constructMatcher("refersToType",
constructMatcher("asString", std::string("int")))))
.getTypedMatcher<Decl>();
EXPECT_TRUE(matches("template<typename T> class A {}; A<int> a;",
HasTemplateArgument));
EXPECT_FALSE(matches("template<typename T> class A {}; A<char> a;",
HasTemplateArgument));
}
TEST_F(RegistryTest, TypeTraversal) {
Matcher<Type> M = constructMatcher(
"pointerType",