[PATCH] D39293: Add objcCategoryImplDecl matcher
Dave Lee via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 25 09:17:13 PDT 2017
kastiglione created this revision.
Herald added a subscriber: klimek.
Add `objcCategoryImplDecl` which matches ObjC category definitions
(`@implementation`). This matcher complements `objcCategoryDecl` (`@interface`)
which was added in https://reviews.llvm.org/D30854.
https://reviews.llvm.org/D39293
Files:
docs/LibASTMatchersReference.html
include/clang/ASTMatchers/ASTMatchers.h
lib/ASTMatchers/Dynamic/Registry.cpp
unittests/ASTMatchers/ASTMatchersNodeTest.cpp
Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===================================================================
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1590,7 +1590,7 @@
)));
}
-TEST(ObjCDeclMacher, CoreDecls) {
+TEST(ObjCDeclMatcher, CoreDecls) {
std::string ObjCString =
"@protocol Proto "
"- (void)protoDidThing; "
@@ -1605,6 +1605,9 @@
"{ id _ivar; } "
"- (void)anything {} "
"@end "
+ "@implementation Thing (ABC) "
+ "- (void)abc_doThing {} "
+ "@end "
;
EXPECT_TRUE(matchesObjC(
@@ -1616,6 +1619,9 @@
EXPECT_TRUE(matchesObjC(
ObjCString,
objcCategoryDecl(hasName("ABC"))));
+ EXPECT_TRUE(matchesObjC(
+ ObjCString,
+ objcCategoryImplDecl(hasName("ABC"))));
EXPECT_TRUE(matchesObjC(
ObjCString,
objcMethodDecl(hasName("protoDidThing"))));
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===================================================================
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -374,6 +374,7 @@
REGISTER_MATCHER(numSelectorArgs);
REGISTER_MATCHER(ofClass);
REGISTER_MATCHER(objcCategoryDecl);
+ REGISTER_MATCHER(objcCategoryImplDecl);
REGISTER_MATCHER(objcImplementationDecl);
REGISTER_MATCHER(objcInterfaceDecl);
REGISTER_MATCHER(objcIvarDecl);
Index: include/clang/ASTMatchers/ASTMatchers.h
===================================================================
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1178,6 +1178,17 @@
Decl,
ObjCCategoryDecl> objcCategoryDecl;
+/// \brief Matches Objective-C category definitions.
+///
+/// Example matches Foo (Additions)
+/// \code
+/// @implementation Foo (Additions)
+/// @end
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher<
+ Decl,
+ ObjCCategoryImplDecl> objcCategoryImplDecl;
+
/// \brief Matches Objective-C method declarations.
///
/// Example matches both declaration and definition of -[Foo method]
Index: docs/LibASTMatchersReference.html
===================================================================
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -346,6 +346,15 @@
</pre></td></tr>
+<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcCategoryImplDecl0')"><a name="objcCategoryImplDecl0Anchor">objcCategoryImplDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryImplDecl.html">ObjCCategoryImplDecl</a>>...</td></tr>
+<tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions.
+
+Example matches Foo (Additions)
+ @implementation Foo (Additions)
+ @end
+</pre></td></tr>
+
+
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcImplementationDecl0')"><a name="objcImplementationDecl0Anchor">objcImplementationDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html">ObjCImplementationDecl</a>>...</td></tr>
<tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39293.120269.patch
Type: text/x-patch
Size: 3361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171025/106e46ea/attachment.bin>
More information about the cfe-commits
mailing list