From 21b3da0f939c699e671dd8df460fce7079361123 Mon Sep 17 00:00:00 2001 From: Samuel Benzaquen Date: Wed, 17 Jul 2013 15:11:30 +0000 Subject: [PATCH] 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 --- clang/lib/ASTMatchers/Dynamic/Registry.cpp | 6 ++---- .../unittests/ASTMatchers/Dynamic/RegistryTest.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp index 4b43b4bf687b..f523cc4abb09 100644 --- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -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); diff --git a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp index d0d42740ab0e..d546fe59ff95 100644 --- a/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp +++ b/clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp @@ -157,6 +157,20 @@ TEST_F(RegistryTest, PolymorphicMatchers) { #endif } +TEST_F(RegistryTest, TemplateArgument) { + Matcher HasTemplateArgument = constructMatcher( + "classTemplateSpecializationDecl", + constructMatcher( + "hasAnyTemplateArgument", + constructMatcher("refersToType", + constructMatcher("asString", std::string("int"))))) + .getTypedMatcher(); + EXPECT_TRUE(matches("template class A {}; A a;", + HasTemplateArgument)); + EXPECT_FALSE(matches("template class A {}; A a;", + HasTemplateArgument)); +} + TEST_F(RegistryTest, TypeTraversal) { Matcher M = constructMatcher( "pointerType",