[PATCH] Add CXXCtorInitializer related matchers to the dynamic matcher registry.
Samuel Benzaquen
sbenza at google.com
Tue Jul 16 14:17:01 PDT 2013
Hi klimek,
Now that CXXCtorInitializer is already supported in ASTNodeKind, add CXXCtorInitializer matchers to the dynamic matcher registry.
http://llvm-reviews.chandlerc.com/D1158
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
@@ -63,12 +63,6 @@
// Need Variant/Parser fixes:
// ofKind
//
- // CXXCtorInitializer support:
- // hasAnyConstructorInitializer
- // forField
- // withInitializer
- // isWritten
- //
// Function overloaded by args:
// hasType
// callee
@@ -149,14 +143,16 @@
REGISTER_MATCHER(explicitCastExpr);
REGISTER_MATCHER(expr);
REGISTER_MATCHER(fieldDecl);
+ REGISTER_MATCHER(forField);
REGISTER_MATCHER(forRangeStmt);
REGISTER_MATCHER(forStmt);
REGISTER_MATCHER(functionDecl);
REGISTER_MATCHER(functionTemplateDecl);
REGISTER_MATCHER(functionType);
REGISTER_MATCHER(functionalCastExpr);
REGISTER_MATCHER(gotoStmt);
REGISTER_MATCHER(hasAnyArgument);
+ REGISTER_MATCHER(hasAnyConstructorInitializer);
REGISTER_MATCHER(hasAnyParameter);
REGISTER_MATCHER(hasAnySubstatement);
REGISTER_MATCHER(hasAnyUsingShadowDecl);
@@ -218,6 +214,7 @@
REGISTER_MATCHER(isPublic);
REGISTER_MATCHER(isTemplateInstantiation);
REGISTER_MATCHER(isVirtual);
+ REGISTER_MATCHER(isWritten);
REGISTER_MATCHER(lValueReferenceType);
REGISTER_MATCHER(labelStmt);
REGISTER_MATCHER(lambdaExpr);
@@ -280,6 +277,7 @@
REGISTER_MATCHER(varDecl);
REGISTER_MATCHER(variableArrayType);
REGISTER_MATCHER(whileStmt);
+ REGISTER_MATCHER(withInitializer);
}
RegistryMaps::~RegistryMaps() {
Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===================================================================
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -173,6 +173,17 @@
EXPECT_TRUE(matches("int b[7];", M));
}
+TEST_F(RegistryTest, CXXCtorInitializer) {
+ Matcher<Decl> CtorDecl = constructMatcher(
+ "constructorDecl",
+ constructMatcher("hasAnyConstructorInitializer",
+ constructMatcher("forField", hasName("foo"))))
+ .getTypedMatcher<Decl>();
+ EXPECT_TRUE(matches("struct Foo { Foo() : foo(1) {} int foo; };", CtorDecl));
+ EXPECT_FALSE(matches("struct Foo { Foo() {} int foo; };", CtorDecl));
+ EXPECT_FALSE(matches("struct Foo { Foo() : bar(1) {} int bar; };", CtorDecl));
+}
+
TEST_F(RegistryTest, Errors) {
// Incorrect argument count.
OwningPtr<Diagnostics> Error(new Diagnostics());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1158.1.patch
Type: text/x-patch
Size: 2457 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130716/4ab50d47/attachment.bin>
More information about the cfe-commits
mailing list