[cfe-commits] r172099 - in /cfe/trunk: lib/Format/Format.cpp test/Index/comment-objc-decls.m unittests/Format/FormatTest.cpp

jahanian fjahanian at apple.com
Thu Jan 10 12:22:50 PST 2013


On Jan 10, 2013, at 12:19 PM, Nico Weber <thakis at chromium.org> wrote:

> Whoops, sorry, I forgot to land the change in include/clang/Format. Do
> things look better after r172101?

Yes. Thanks.
- Fariborz

> 
> On Thu, Jan 10, 2013 at 12:16 PM, jahanian <fjahanian at apple.com> wrote:
>> Hi Nico,
>> I am seeing build error.
>> 
>> llvm[4]: Compiling SemaTemplateDeduction.cpp for Debug+Asserts build
>> /Users/jahanian/sandbox/llvm-tot/tools/clang/lib/Format/Format.cpp:107:13: error: no member named 'ObjCSpaceBeforeProtocolList' in
>>      'clang::format::FormatStyle'
>>  LLVMStyle.ObjCSpaceBeforeProtocolList = true;
>>  ~~~~~~~~~ ^
>> /Users/jahanian/sandbox/llvm-tot/tools/clang/lib/Format/Format.cpp:120:15: error: no member named 'ObjCSpaceBeforeProtocolList' in
>>      'clang::format::FormatStyle'
>>  GoogleStyle.ObjCSpaceBeforeProtocolList = false;
>>  ~~~~~~~~~~~ ^
>> /Users/jahanian/sandbox/llvm-tot/tools/clang/lib/Format/Format.cpp:981:51: error: no member named 'ObjCSpaceBeforeProtocolList' in
>>      'clang::format::FormatStyle'
>>         (CurrentLineType == LT_ObjCDecl && Style.ObjCSpaceBeforeProtocolList)))
>>                                            ~~~~~ ^
>> 
>> - Fariborz
>> 
>> On Jan 10, 2013, at 12:12 PM, Nico Weber <nicolasweber at gmx.de> wrote:
>> 
>>> Author: nico
>>> Date: Thu Jan 10 14:12:55 2013
>>> New Revision: 172099
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=172099&view=rev
>>> Log:
>>> Formatting: In @implementation etc lines, put a space before protocol lists.
>>> 
>>> Don't do this in Google style though:
>>> http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Protocols
>>> 
>>> Most other places (function declarations, variable declarations) still get
>>> this wrong, and since this looks very similiar to template instantiations to
>>> the lexer (`id <MyProtocol> a = ...`), it's going to be hard to fix in some
>>> places.
>>> 
>>> 
>>> Modified:
>>>   cfe/trunk/lib/Format/Format.cpp
>>>   cfe/trunk/test/Index/comment-objc-decls.m
>>>   cfe/trunk/unittests/Format/FormatTest.cpp
>>> 
>>> Modified: cfe/trunk/lib/Format/Format.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=172099&r1=172098&r2=172099&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/lib/Format/Format.cpp (original)
>>> +++ cfe/trunk/lib/Format/Format.cpp Thu Jan 10 14:12:55 2013
>>> @@ -104,6 +104,7 @@
>>>  LLVMStyle.SplitTemplateClosingGreater = true;
>>>  LLVMStyle.IndentCaseLabels = false;
>>>  LLVMStyle.SpacesBeforeTrailingComments = 1;
>>> +  LLVMStyle.ObjCSpaceBeforeProtocolList = true;
>>>  return LLVMStyle;
>>> }
>>> 
>>> @@ -116,6 +117,7 @@
>>>  GoogleStyle.SplitTemplateClosingGreater = false;
>>>  GoogleStyle.IndentCaseLabels = true;
>>>  GoogleStyle.SpacesBeforeTrailingComments = 2;
>>> +  GoogleStyle.ObjCSpaceBeforeProtocolList = false;
>>>  return GoogleStyle;
>>> }
>>> 
>>> @@ -974,7 +976,9 @@
>>>      return Right.is(tok::hash);
>>>    if (Right.is(tok::r_paren) || Right.is(tok::semi) || Right.is(tok::comma))
>>>      return false;
>>> -    if (Left.is(tok::kw_template) && Right.is(tok::less))
>>> +    if (Right.is(tok::less) &&
>>> +        (Left.is(tok::kw_template) ||
>>> +         (CurrentLineType == LT_ObjCDecl && Style.ObjCSpaceBeforeProtocolList)))
>>>      return true;
>>>    if (Left.is(tok::arrow) || Right.is(tok::arrow))
>>>      return false;
>>> 
>>> Modified: cfe/trunk/test/Index/comment-objc-decls.m
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-objc-decls.m?rev=172099&r1=172098&r2=172099&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/test/Index/comment-objc-decls.m (original)
>>> +++ cfe/trunk/test/Index/comment-objc-decls.m Thu Jan 10 14:12:55 2013
>>> @@ -73,7 +73,7 @@
>>> */
>>> @property (copy) id PropertyMyClass;
>>> @end
>>> -// CHECK: <Declaration>@interface MyClass : NSObject<MyProto> {\n    id IvarMyClass;\n}\n at end</Declaration>
>>> +// CHECK: <Declaration>@interface MyClass : NSObject <MyProto> {\n    id IvarMyClass;\n}\n at end</Declaration>
>>> // CHECK: <Declaration>id IvarMyClass</Declaration>
>>> // CHECK: <Declaration>- (id)MethodMyClass;</Declaration>
>>> // CHECK: <Declaration>+ (id)ClassMethodMyClass;</Declaration>
>>> 
>>> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172099&r1=172098&r2=172099&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
>>> +++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jan 10 14:12:55 2013
>>> @@ -1186,7 +1186,7 @@
>>> TEST_F(FormatTest, FormatObjCInterface) {
>>>  // FIXME: Handle comments like in "@interface /* wait for it */ Foo", PR14875
>>>  // FIXME: In google style, it's "+(id) init", not "+ (id)init".
>>> -  verifyFormat("@interface Foo : NSObject<NSSomeDelegate> {\n"
>>> +  verifyFormat("@interface Foo : NSObject <NSSomeDelegate> {\n"
>>>               "@public\n"
>>>               "  int field1;\n"
>>>               "@protected\n"
>>> @@ -1199,7 +1199,6 @@
>>>               "+ (id)init;\n"
>>>               "@end");
>>> 
>>> -  // FIXME: In LLVM style, there should be a space before '<' for protocols.
>>>  verifyGoogleFormat("@interface Foo : NSObject<NSSomeDelegate> {\n"
>>>                     " @public\n"
>>>                     "  int field1;\n"
>>> @@ -1228,10 +1227,14 @@
>>>               "+ (id)init;\n"
>>>               "@end");
>>> 
>>> -  verifyFormat("@interface Foo : Bar<Baz, Quux>\n"
>>> +  verifyFormat("@interface Foo : Bar <Baz, Quux>\n"
>>>               "+ (id)init;\n"
>>>               "@end");
>>> 
>>> +  verifyGoogleFormat("@interface Foo : Bar<Baz, Quux>\n"
>>> +                     "+ (id)init;\n"
>>> +                     "@end");
>>> +
>>>  verifyFormat("@interface Foo (HackStuff)\n"
>>>               "+ (id)init;\n"
>>>               "@end");
>>> @@ -1240,10 +1243,14 @@
>>>               "+ (id)init;\n"
>>>               "@end");
>>> 
>>> -  verifyFormat("@interface Foo (HackStuff)<MyProtocol>\n"
>>> +  verifyFormat("@interface Foo (HackStuff) <MyProtocol>\n"
>>>               "+ (id)init;\n"
>>>               "@end");
>>> 
>>> +  verifyGoogleFormat("@interface Foo (HackStuff)<MyProtocol>\n"
>>> +                     "+ (id)init;\n"
>>> +                     "@end");
>>> +
>>>  verifyFormat("@interface Foo {\n"
>>>               "  int _i;\n"
>>>               "}\n"
>>> @@ -1256,7 +1263,7 @@
>>>               "+ (id)init;\n"
>>>               "@end");
>>> 
>>> -  verifyFormat("@interface Foo : Bar<Baz, Quux> {\n"
>>> +  verifyFormat("@interface Foo : Bar <Baz, Quux> {\n"
>>>               "  int _i;\n"
>>>               "}\n"
>>>               "+ (id)init;\n"
>>> @@ -1274,7 +1281,7 @@
>>>               "+ (id)init;\n"
>>>               "@end");
>>> 
>>> -  verifyFormat("@interface Foo (HackStuff)<MyProtocol> {\n"
>>> +  verifyFormat("@interface Foo (HackStuff) <MyProtocol> {\n"
>>>               "  int _i;\n"
>>>               "}\n"
>>>               "+ (id)init;\n"
>>> @@ -1351,11 +1358,14 @@
>>>               "- (NSUInteger)numberOfThings;\n"
>>>               "@end");
>>> 
>>> -  // FIXME: In LLVM style, there should be a space before '<' for protocols.
>>> -  verifyFormat("@protocol MyProtocol<NSObject>\n"
>>> +  verifyFormat("@protocol MyProtocol <NSObject>\n"
>>>               "- (NSUInteger)numberOfThings;\n"
>>>               "@end");
>>> 
>>> +  verifyGoogleFormat("@protocol MyProtocol<NSObject>\n"
>>> +                     "- (NSUInteger)numberOfThings;\n"
>>> +                     "@end");
>>> +
>>>  verifyFormat("@protocol Foo;\n"
>>>               "@protocol Bar;\n");
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list