[PATCH] Add TemplateArgument related matchers to the registry.
Samuel Benzaquen
sbenza at google.com
Wed Jul 17 07:33:21 PDT 2013
Hi klimek,
Continue adding more matchers to the dynamic registry.
This time, we add TemplateArgument matchers.
http://llvm-reviews.chandlerc.com/D1166
Files:
lib/ASTMatchers/Dynamic/Registry.cpp
unittests/ASTMatchers/Dynamic/RegistryTest.cpp
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===================================================================
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -56,10 +56,6 @@
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 @@
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 @@
REGISTER_MATCHER(hasSizeExpr);
REGISTER_MATCHER(hasSourceExpression);
REGISTER_MATCHER(hasTargetDecl);
+ REGISTER_MATCHER(hasTemplateArgument);
REGISTER_MATCHER(hasTrueExpression);
REGISTER_MATCHER(hasUnaryOperand);
REGISTER_MATCHER(hasValueType);
Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===================================================================
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -157,6 +157,20 @@
#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",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1166.1.patch
Type: text/x-patch
Size: 2024 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130717/18a02b09/attachment.bin>
More information about the cfe-commits
mailing list