Summary:
Add `objcCategoryImplDecl` which matches ObjC category definitions
(`@implementation`). This matcher complements `objcCategoryDecl` (`@interface`)
which was added in D30854.
Reviewers: aaron.ballman, malcolm.parsons, alexshap
Reviewed By: aaron.ballman
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D39293
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316670
91177308-0d34-0410-b5e6-
96231b3b80d8
</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.
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]
REGISTER_MATCHER(numSelectorArgs);
REGISTER_MATCHER(ofClass);
REGISTER_MATCHER(objcCategoryDecl);
+ REGISTER_MATCHER(objcCategoryImplDecl);
REGISTER_MATCHER(objcImplementationDecl);
REGISTER_MATCHER(objcInterfaceDecl);
REGISTER_MATCHER(objcIvarDecl);
)));
}
-TEST(ObjCDeclMacher, CoreDecls) {
+TEST(ObjCDeclMatcher, CoreDecls) {
std::string ObjCString =
"@protocol Proto "
"- (void)protoDidThing; "
"{ id _ivar; } "
"- (void)anything {} "
"@end "
+ "@implementation Thing (ABC) "
+ "- (void)abc_doThing {} "
+ "@end "
;
EXPECT_TRUE(matchesObjC(
EXPECT_TRUE(matchesObjC(
ObjCString,
objcCategoryDecl(hasName("ABC"))));
+ EXPECT_TRUE(matchesObjC(
+ ObjCString,
+ objcCategoryImplDecl(hasName("ABC"))));
EXPECT_TRUE(matchesObjC(
ObjCString,
objcMethodDecl(hasName("protoDidThing"))));