diff options
| author | Dave Lee <davelee.com@gmail.com> | 2017-09-10 21:00:15 +0000 |
|---|---|---|
| committer | Dave Lee <davelee.com@gmail.com> | 2017-09-10 21:00:15 +0000 |
| commit | e6d362cea8a99eba3fe868934aa191d66f8a7540 (patch) | |
| tree | 7c1f758b0e811d05d7a28fbe52a6038cc0a29fd5 | |
| parent | b1db6b7d3903ab3fd98e3b17dd89976a24323482 (diff) | |
| download | bcm5719-llvm-e6d362cea8a99eba3fe868934aa191d66f8a7540.tar.gz bcm5719-llvm-e6d362cea8a99eba3fe868934aa191d66f8a7540.zip | |
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
llvm-svn: 312889
| -rw-r--r-- | clang/docs/LibASTMatchersReference.html | 9 | ||||
| -rw-r--r-- | clang/include/clang/ASTMatchers/ASTMatchers.h | 11 | ||||
| -rw-r--r-- | clang/lib/ASTMatchers/Dynamic/Registry.cpp | 1 | ||||
| -rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp | 3 |
4 files changed, 24 insertions, 0 deletions
diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index ac90c1e629e..11006bb9ac7 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -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. diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index 8c1b082fc8d..21a6c2bb76a 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -1145,6 +1145,17 @@ const internal::VariadicDynCastAllOfMatcher< 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 diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp index 3244d2ef15f..4bd7a520c87 100644 --- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -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); diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp index 712c3854c48..beb6ed880a0 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -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, |

