benhamilton created this revision. Herald added a subscriber: cfe-commits. 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 Repository: rC Clang https://reviews.llvm.org/D41074 Files: lib/Format/Format.cpp unittests/Format/FormatTestObjC.cpp Index: unittests/Format/FormatTestObjC.cpp =================================================================== --- unittests/Format/FormatTestObjC.cpp +++ unittests/Format/FormatTestObjC.cpp @@ -200,7 +200,7 @@ "@end"); Style = getGoogleStyle(FormatStyle::LK_ObjC); - verifyFormat("@interface Foo : NSObject<NSSomeDelegate> {\n" + verifyFormat("@interface Foo : NSObject <NSSomeDelegate> {\n" " @public\n" " int field1;\n" " @protected\n" @@ -212,15 +212,15 @@ "}\n" "+ (id)init;\n" "@end"); - verifyFormat("@interface Foo : Bar<Baz, Quux>\n" + verifyFormat("@interface Foo : Bar <Baz, Quux>\n" "+ (id)init;\n" "@end"); - verifyFormat("@interface Foo (HackStuff)<MyProtocol>\n" + verifyFormat("@interface Foo (HackStuff) <MyProtocol>\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" @@ -343,7 +343,7 @@ "@end"); Style = getGoogleStyle(FormatStyle::LK_ObjC); - verifyFormat("@protocol MyProtocol<NSObject>\n" + verifyFormat("@protocol MyProtocol <NSObject>\n" "- (NSUInteger)numberOfThings;\n" "@end"); } Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -693,7 +693,7 @@ GoogleStyle.IndentCaseLabels = true; GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false; GoogleStyle.ObjCSpaceAfterProperty = false; - GoogleStyle.ObjCSpaceBeforeProtocolList = false; + GoogleStyle.ObjCSpaceBeforeProtocolList = true; GoogleStyle.PointerAlignment = FormatStyle::PAS_Left; GoogleStyle.SpacesBeforeTrailingComments = 2; GoogleStyle.Standard = FormatStyle::LS_Auto;
Index: unittests/Format/FormatTestObjC.cpp =================================================================== --- unittests/Format/FormatTestObjC.cpp +++ unittests/Format/FormatTestObjC.cpp @@ -200,7 +200,7 @@ "@end"); Style = getGoogleStyle(FormatStyle::LK_ObjC); - verifyFormat("@interface Foo : NSObject<NSSomeDelegate> {\n" + verifyFormat("@interface Foo : NSObject <NSSomeDelegate> {\n" " @public\n" " int field1;\n" " @protected\n" @@ -212,15 +212,15 @@ "}\n" "+ (id)init;\n" "@end"); - verifyFormat("@interface Foo : Bar<Baz, Quux>\n" + verifyFormat("@interface Foo : Bar <Baz, Quux>\n" "+ (id)init;\n" "@end"); - verifyFormat("@interface Foo (HackStuff)<MyProtocol>\n" + verifyFormat("@interface Foo (HackStuff) <MyProtocol>\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" @@ -343,7 +343,7 @@ "@end"); Style = getGoogleStyle(FormatStyle::LK_ObjC); - verifyFormat("@protocol MyProtocol<NSObject>\n" + verifyFormat("@protocol MyProtocol <NSObject>\n" "- (NSUInteger)numberOfThings;\n" "@end"); } Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -693,7 +693,7 @@ GoogleStyle.IndentCaseLabels = true; GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false; GoogleStyle.ObjCSpaceAfterProperty = false; - GoogleStyle.ObjCSpaceBeforeProtocolList = false; + GoogleStyle.ObjCSpaceBeforeProtocolList = true; GoogleStyle.PointerAlignment = FormatStyle::PAS_Left; GoogleStyle.SpacesBeforeTrailingComments = 2; GoogleStyle.Standard = FormatStyle::LS_Auto;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits