Author: kastiglione Date: Sun Sep 10 14:00:15 2017 New Revision: 312889 URL: http://llvm.org/viewvc/llvm-project?rev=312889&view=rev Log: Add objcImplementationDecl matcher
Summary: Add the `objcImplementationDecl` matcher. See related: D30854 Tested with: ``` ./tools/clang/unittests/ASTMatchers/ASTMatchersTests ``` Reviewers: aaron.ballman, compnerd, alexshap Reviewed By: aaron.ballman Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37643 Modified: cfe/trunk/docs/LibASTMatchersReference.html cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Modified: cfe/trunk/docs/LibASTMatchersReference.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=312889&r1=312888&r2=312889&view=diff ============================================================================== --- cfe/trunk/docs/LibASTMatchersReference.html (original) +++ cfe/trunk/docs/LibASTMatchersReference.html Sun Sep 10 14:00:15 2017 @@ -346,6 +346,15 @@ Example matches Foo (Additions) </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. + +Example matches Foo + @implementation Foo + @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('objcInterfaceDecl0')"><a name="objcInterfaceDecl0Anchor">objcInterfaceDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>>...</td></tr> <tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations. Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=312889&r1=312888&r2=312889&view=diff ============================================================================== --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sun Sep 10 14:00:15 2017 @@ -1145,6 +1145,17 @@ const internal::VariadicDynCastAllOfMatc Decl, ObjCInterfaceDecl> objcInterfaceDecl; +/// \brief Matches Objective-C implementation declarations. +/// +/// Example matches Foo +/// \code +/// @implementation Foo +/// @end +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Decl, + ObjCImplementationDecl> objcImplementationDecl; + /// \brief Matches Objective-C protocol declarations. /// /// Example matches FooDelegate Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=312889&r1=312888&r2=312889&view=diff ============================================================================== --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original) +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Sun Sep 10 14:00:15 2017 @@ -374,6 +374,7 @@ RegistryMaps::RegistryMaps() { REGISTER_MATCHER(numSelectorArgs); REGISTER_MATCHER(ofClass); REGISTER_MATCHER(objcCategoryDecl); + REGISTER_MATCHER(objcImplementationDecl); REGISTER_MATCHER(objcInterfaceDecl); REGISTER_MATCHER(objcIvarDecl); REGISTER_MATCHER(objcMessageExpr); Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp?rev=312889&r1=312888&r2=312889&view=diff ============================================================================== --- cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp (original) +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp Sun Sep 10 14:00:15 2017 @@ -1612,6 +1612,9 @@ TEST(ObjCDeclMacher, CoreDecls) { objcProtocolDecl(hasName("Proto")))); EXPECT_TRUE(matchesObjC( ObjCString, + objcImplementationDecl(hasName("Thing")))); + EXPECT_TRUE(matchesObjC( + ObjCString, objcCategoryDecl(hasName("ABC")))); EXPECT_TRUE(matchesObjC( ObjCString, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits