r186514 - Add TemplateArgument related matchers to the registry.
Samuel Benzaquen
sbenza at google.com
Wed Jul 17 08:11:30 PDT 2013
Author: sbenza
Date: Wed Jul 17 10:11:30 2013
New Revision: 186514
URL: http://llvm.org/viewvc/llvm-project?rev=186514&view=rev
Log:
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
Modified:
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=186514&r1=186513&r2=186514&view=diff
==============================================================================
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Wed Jul 17 10:11:30 2013
@@ -56,10 +56,6 @@ void RegistryMaps::registerMatcher(Strin
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);
Modified: cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp?rev=186514&r1=186513&r2=186514&view=diff
==============================================================================
--- cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp Wed Jul 17 10:11:30 2013
@@ -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",
More information about the cfe-commits
mailing list