Author: nico Date: Thu Jan 17 00:14:50 2013 New Revision: 172703 URL: http://llvm.org/viewvc/llvm-project?rev=172703&view=rev Log: Revert most of r172140.
r172140 changed the formatter to produce "-(id) foo" instead of "- (id)foo" in google style, with a link to http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Method_Declarations_and_Definitions as reference. But now that I look at that link again, it seems I didn't read it very carefully the first time round. Modified: cfe/trunk/include/clang/Format/Format.h cfe/trunk/lib/Format/Format.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/include/clang/Format/Format.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=172703&r1=172702&r2=172703&view=diff ============================================================================== --- cfe/trunk/include/clang/Format/Format.h (original) +++ cfe/trunk/include/clang/Format/Format.h Thu Jan 17 00:14:50 2013 @@ -71,10 +71,6 @@ /// \brief Add a space in front of an Objective-C protocol list, i.e. use /// Foo <Protocol> instead of Foo<Protocol>. bool ObjCSpaceBeforeProtocolList; - - /// \brief Add a space in front method return types, i.e. use - /// + (id)init instead of +(id) init - bool ObjCSpaceBeforeReturnType; }; /// \brief Returns a format style complying with the LLVM coding standards: Modified: cfe/trunk/lib/Format/Format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=172703&r1=172702&r2=172703&view=diff ============================================================================== --- cfe/trunk/lib/Format/Format.cpp (original) +++ cfe/trunk/lib/Format/Format.cpp Thu Jan 17 00:14:50 2013 @@ -46,7 +46,6 @@ TT_ObjCDecl, TT_ObjCMethodSpecifier, TT_ObjCMethodExpr, - TT_ObjCSelectorStart, TT_ObjCProperty, TT_OverloadedOperator, TT_PointerOrReference, @@ -152,7 +151,6 @@ LLVMStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = false; LLVMStyle.AllowShortIfStatementsOnASingleLine = false; LLVMStyle.ObjCSpaceBeforeProtocolList = true; - LLVMStyle.ObjCSpaceBeforeReturnType = true; return LLVMStyle; } @@ -169,7 +167,6 @@ GoogleStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = true; GoogleStyle.AllowShortIfStatementsOnASingleLine = false; GoogleStyle.ObjCSpaceBeforeProtocolList = false; - GoogleStyle.ObjCSpaceBeforeReturnType = false; return GoogleStyle; } @@ -892,14 +889,8 @@ Tok->Type = TT_ObjCMethodExpr; break; case tok::l_paren: { - bool ParensWereObjCReturnType = Tok->Parent && Tok->Parent->Type == - TT_ObjCMethodSpecifier; if (!parseParens()) return false; - if (CurrentToken != NULL && ParensWereObjCReturnType) { - CurrentToken->Type = TT_ObjCSelectorStart; - next(); - } } break; case tok::l_square: if (!parseSquare()) @@ -1308,9 +1299,7 @@ if (Tok.is(tok::colon)) return false; if (Tok.Parent->Type == TT_ObjCMethodSpecifier) - return Style.ObjCSpaceBeforeReturnType || Tok.isNot(tok::l_paren); - if (Tok.Type == TT_ObjCSelectorStart) - return !Style.ObjCSpaceBeforeReturnType; + return true; if (Tok.Parent->is(tok::r_paren) && Tok.is(tok::identifier)) // Don't space between ')' and <id> return false; Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172703&r1=172702&r2=172703&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jan 17 00:14:50 2013 @@ -1473,13 +1473,13 @@ "outRange8:(NSRange) out_range8 outRange9:(NSRange) out_range9;")); verifyFormat("- (int)sum:(vector<int>)numbers;"); - verifyGoogleFormat("-(void) setDelegate:(id<Protocol>)delegate;"); + verifyGoogleFormat("- (void)setDelegate:(id<Protocol>)delegate;"); // FIXME: In LLVM style, there should be a space in front of a '<' for ObjC // protocol lists (but not for template classes): //verifyFormat("- (void)setDelegate:(id <Protocol>)delegate;"); verifyFormat("- (int(*)())foo:(int(*)())f;"); - verifyGoogleFormat("-(int(*)()) foo:(int(*)())foo;"); + verifyGoogleFormat("- (int(*)())foo:(int(*)())foo;"); // If there's no return type (very rare in practice!), LLVM and Google style // agree. @@ -1517,7 +1517,7 @@ " @package\n" " int field4;\n" "}\n" - "+(id) init;\n" + "+ (id)init;\n" "@end"); verifyFormat("@interface Foo\n" @@ -1540,7 +1540,7 @@ "@end"); verifyGoogleFormat("@interface Foo : Bar<Baz, Quux>\n" - "+(id) init;\n" + "+ (id)init;\n" "@end"); verifyFormat("@interface Foo (HackStuff)\n" @@ -1556,7 +1556,7 @@ "@end"); verifyGoogleFormat("@interface Foo (HackStuff)<MyProtocol>\n" - "+(id) init;\n" + "+ (id)init;\n" "@end"); verifyFormat("@interface Foo {\n" @@ -1620,7 +1620,7 @@ " @package\n" " int field4;\n" "}\n" - "+(id) init {}\n" + "+ (id)init {}\n" "@end"); verifyFormat("@implementation Foo\n" @@ -1675,7 +1675,7 @@ "@end"); verifyGoogleFormat("@protocol MyProtocol<NSObject>\n" - "-(NSUInteger) numberOfThings;\n" + "- (NSUInteger)numberOfThings;\n" "@end"); verifyFormat("@protocol Foo;\n" _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
