]> granicus.if.org Git - clang/commitdiff
Add objcImplementationDecl matcher
authorDave Lee <davelee.com@gmail.com>
Sun, 10 Sep 2017 21:00:15 +0000 (21:00 +0000)
committerDave Lee <davelee.com@gmail.com>
Sun, 10 Sep 2017 21:00:15 +0000 (21:00 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312889 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LibASTMatchersReference.html
include/clang/ASTMatchers/ASTMatchers.h
lib/ASTMatchers/Dynamic/Registry.cpp
unittests/ASTMatchers/ASTMatchersNodeTest.cpp

index ac90c1e629e664edc6e21c41bcb28a8633fae994..11006bb9ac759044c2ac9f859a37d51d3a3789c5 100644 (file)
@@ -346,6 +346,15 @@ Example matches Foo (Additions)
 </pre></td></tr>
 
 
+<tr><td>Matcher&lt;<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('objcImplementationDecl0')"><a name="objcImplementationDecl0Anchor">objcImplementationDecl</a></td><td>Matcher&lt;<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html">ObjCImplementationDecl</a>&gt;...</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&lt;<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('objcInterfaceDecl0')"><a name="objcInterfaceDecl0Anchor">objcInterfaceDecl</a></td><td>Matcher&lt;<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>&gt;...</td></tr>
 <tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations.
 
index 8c1b082fc8d1fd09e2ecbb42bbd67e56f319d6dd..21a6c2bb76aa3a93402a5ed972d1ae101e827ff6 100644 (file)
@@ -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
index 3244d2ef15f2b08a8e0657b7b34cca6a34fb1093..4bd7a520c872b70c6749ca9693ba9a04e52e8b4d 100644 (file)
@@ -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);
index 712c3854c483f386852f4894c4f08b62a9bb9e1c..beb6ed880a035e0b55542c5a86eaebef06ff4658 100644 (file)
@@ -1610,6 +1610,9 @@ TEST(ObjCDeclMacher, CoreDecls) {
   EXPECT_TRUE(matchesObjC(
     ObjCString,
     objcProtocolDecl(hasName("Proto"))));
+  EXPECT_TRUE(matchesObjC(
+    ObjCString,
+    objcImplementationDecl(hasName("Thing"))));
   EXPECT_TRUE(matchesObjC(
     ObjCString,
     objcCategoryDecl(hasName("ABC"))));