[PATCH] D37192: [clang-format] Add support for generic Obj-C categories

Daniel Martín via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 28 00:13:16 PDT 2017


danielmartin updated this revision to Diff 112855.
danielmartin added a comment.

Make comment fit in one line


https://reviews.llvm.org/D37192

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===================================================================
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -821,6 +821,13 @@
                "  NSBundle.mainBundle.infoDictionary[@\"a\"]\n"
                "]];");
 }
+
+TEST_F(FormatTestObjC, FormatGenericObjCCategory) {
+  verifyFormat(
+      "@interface NSHashTable <ObjectType>(MYFoundation)\n"
+      "- (void)xyz_addObjectsFromArray:(nonnull NSArray<ObjectType> *)array;\n"
+      "@end");
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/UnwrappedLineParser.cpp
===================================================================
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -2096,6 +2096,10 @@
   if (FormatTok->Tok.is(tok::less))
     parseObjCProtocolList();
 
+  // After a protocol list, we can have a category (Obj-C generic category).
+  if (FormatTok->Tok.is(tok::l_paren))
+    parseParens();
+
   if (FormatTok->Tok.is(tok::l_brace)) {
     if (Style.BraceWrapping.AfterObjCDeclaration)
       addUnwrappedLine();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37192.112855.patch
Type: text/x-patch
Size: 1150 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170828/8a03bbd2/attachment-0001.bin>


More information about the cfe-commits mailing list