r214508 - clang-format: Add a space in ObjC protocols.
Daniel Jasper
djasper at google.com
Fri Aug 1 06:03:05 PDT 2014
Author: djasper
Date: Fri Aug 1 08:03:05 2014
New Revision: 214508
URL: http://llvm.org/viewvc/llvm-project?rev=214508&view=rev
Log:
clang-format: Add a space in ObjC protocols.
Before:
@interface Foo (HackStuff)<MyProtocol>
After:
@interface Foo (HackStuff) <MyProtocol>
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=214508&r1=214507&r2=214508&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Aug 1 08:03:05 2014
@@ -1480,7 +1480,7 @@ bool TokenAnnotator::spaceRequiredBetwee
if (Right.isOneOf(tok::semi, tok::comma))
return false;
if (Right.is(tok::less) &&
- (Left.is(tok::kw_template) ||
+ (Left.isOneOf(tok::kw_template, tok::r_paren) ||
(Line.Type == LT_ObjCDecl && Style.ObjCSpaceBeforeProtocolList)))
return true;
if (Left.is(tok::arrow) || Right.is(tok::arrow))
@@ -1509,13 +1509,14 @@ bool TokenAnnotator::spaceRequiredBetwee
((Left.Type != TT_PointerOrReference) && Left.isNot(tok::l_paren) &&
Style.PointerAlignment != FormatStyle::PAS_Left);
if (Right.Type == TT_FunctionTypeLParen && Left.isNot(tok::l_paren) &&
- (Left.Type != TT_PointerOrReference || Style.PointerAlignment != FormatStyle::PAS_Right))
+ (Left.Type != TT_PointerOrReference ||
+ Style.PointerAlignment != FormatStyle::PAS_Right))
return true;
if (Left.Type == TT_PointerOrReference)
return Right.Tok.isLiteral() || Right.Type == TT_BlockComment ||
((Right.Type != TT_PointerOrReference) &&
- Right.isNot(tok::l_paren) && Style.PointerAlignment != FormatStyle::PAS_Right &&
- Left.Previous &&
+ Right.isNot(tok::l_paren) &&
+ Style.PointerAlignment != FormatStyle::PAS_Right && Left.Previous &&
!Left.Previous->isOneOf(tok::l_paren, tok::coloncolon));
if (Right.is(tok::star) && Left.is(tok::l_paren))
return false;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=214508&r1=214507&r2=214508&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Aug 1 08:03:05 2014
@@ -6119,7 +6119,7 @@ TEST_F(FormatTest, FormatObjCInterface)
"+ (id)init;\n"
"@end");
- verifyGoogleFormat("@interface Foo (HackStuff)<MyProtocol>\n"
+ verifyGoogleFormat("@interface Foo (HackStuff) <MyProtocol>\n"
"+ (id)init;\n"
"@end");
@@ -6161,7 +6161,7 @@ TEST_F(FormatTest, FormatObjCInterface)
FormatStyle OnePerLine = getGoogleStyle();
OnePerLine.BinPackParameters = false;
- verifyFormat("@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()<\n"
+ verifyFormat("@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa () <\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
More information about the cfe-commits
mailing list