Skip to content

Commit f84f118

Browse files
committedJan 18, 2018
[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 llvm-svn: 322873
1 parent 1885052 commit f84f118

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎clang/lib/Format/Format.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
694694
GoogleStyle.IndentCaseLabels = true;
695695
GoogleStyle.KeepEmptyLinesAtTheStartOfBlocks = false;
696696
GoogleStyle.ObjCSpaceAfterProperty = false;
697-
GoogleStyle.ObjCSpaceBeforeProtocolList = false;
697+
GoogleStyle.ObjCSpaceBeforeProtocolList = true;
698698
GoogleStyle.PointerAlignment = FormatStyle::PAS_Left;
699699
GoogleStyle.RawStringFormats = {{
700700
FormatStyle::LK_TextProto,

‎clang/unittests/Format/FormatTestObjC.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ TEST_F(FormatTestObjC, FormatObjCInterface) {
271271
"@end");
272272

273273
Style = getGoogleStyle(FormatStyle::LK_ObjC);
274-
verifyFormat("@interface Foo : NSObject<NSSomeDelegate> {\n"
274+
verifyFormat("@interface Foo : NSObject <NSSomeDelegate> {\n"
275275
" @public\n"
276276
" int field1;\n"
277277
" @protected\n"
@@ -283,15 +283,15 @@ TEST_F(FormatTestObjC, FormatObjCInterface) {
283283
"}\n"
284284
"+ (id)init;\n"
285285
"@end");
286-
verifyFormat("@interface Foo : Bar<Baz, Quux>\n"
286+
verifyFormat("@interface Foo : Bar <Baz, Quux>\n"
287287
"+ (id)init;\n"
288288
"@end");
289-
verifyFormat("@interface Foo (HackStuff)<MyProtocol>\n"
289+
verifyFormat("@interface Foo (HackStuff) <MyProtocol>\n"
290290
"+ (id)init;\n"
291291
"@end");
292292
Style.BinPackParameters = false;
293293
Style.ColumnLimit = 80;
294-
verifyFormat("@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()<\n"
294+
verifyFormat("@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa () <\n"
295295
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
296296
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
297297
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
@@ -414,7 +414,7 @@ TEST_F(FormatTestObjC, FormatObjCProtocol) {
414414
"@end");
415415

416416
Style = getGoogleStyle(FormatStyle::LK_ObjC);
417-
verifyFormat("@protocol MyProtocol<NSObject>\n"
417+
verifyFormat("@protocol MyProtocol <NSObject>\n"
418418
"- (NSUInteger)numberOfThings;\n"
419419
"@end");
420420
}

0 commit comments

Comments
 (0)
Please sign in to comment.