From: Ben Hamilton Date: Thu, 18 Jan 2018 18:37:16 +0000 (+0000) Subject: [ClangFormat] ObjCSpaceBeforeProtocolList should be true in the google style X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a8bf4d5625e5df9e4d3d597858ce777161b0aea4;p=clang [ClangFormat] ObjCSpaceBeforeProtocolList should be true in the google style Summary: The Google style guide is neutral on whether there should be a space before the protocol list in an Objective-C @interface or @implementation. The majority of Objective-C code in both Apple's public header files and Google's open-source uses a space before the protocol list, so this changes the google style to default ObjCSpaceBeforeProtocolList to true. Test Plan: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: krasimir, djasper, klimek Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D41074 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322873 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 3044b3a56e..88c90a865a 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -694,7 +694,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) { GoogleStyle.IndentCaseLabels = true; GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false; GoogleStyle.ObjCSpaceAfterProperty = false; - GoogleStyle.ObjCSpaceBeforeProtocolList = false; + GoogleStyle.ObjCSpaceBeforeProtocolList = true; GoogleStyle.PointerAlignment = FormatStyle::PAS_Left; GoogleStyle.RawStringFormats = {{ FormatStyle::LK_TextProto, diff --git a/unittests/Format/FormatTestObjC.cpp b/unittests/Format/FormatTestObjC.cpp index 41ff89f92e..6cb5729e25 100644 --- a/unittests/Format/FormatTestObjC.cpp +++ b/unittests/Format/FormatTestObjC.cpp @@ -271,7 +271,7 @@ TEST_F(FormatTestObjC, FormatObjCInterface) { "@end"); Style = getGoogleStyle(FormatStyle::LK_ObjC); - verifyFormat("@interface Foo : NSObject {\n" + verifyFormat("@interface Foo : NSObject {\n" " @public\n" " int field1;\n" " @protected\n" @@ -283,15 +283,15 @@ TEST_F(FormatTestObjC, FormatObjCInterface) { "}\n" "+ (id)init;\n" "@end"); - verifyFormat("@interface Foo : Bar\n" + verifyFormat("@interface Foo : Bar \n" "+ (id)init;\n" "@end"); - verifyFormat("@interface Foo (HackStuff)\n" + verifyFormat("@interface Foo (HackStuff) \n" "+ (id)init;\n" "@end"); Style.BinPackParameters = false; Style.ColumnLimit = 80; - verifyFormat("@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()<\n" + verifyFormat("@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa () <\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" @@ -414,7 +414,7 @@ TEST_F(FormatTestObjC, FormatObjCProtocol) { "@end"); Style = getGoogleStyle(FormatStyle::LK_ObjC); - verifyFormat("@protocol MyProtocol\n" + verifyFormat("@protocol MyProtocol \n" "- (NSUInteger)numberOfThings;\n" "@end"); }