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();
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();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits