]> granicus.if.org Git - clang/commitdiff
clang-format: Add a space in ObjC protocols.
authorDaniel Jasper <djasper@google.com>
Fri, 1 Aug 2014 13:03:05 +0000 (13:03 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 1 Aug 2014 13:03:05 +0000 (13:03 +0000)
Before:
  @interface Foo (HackStuff)<MyProtocol>

After:
  @interface Foo (HackStuff) <MyProtocol>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214508 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index 6f77ae3d29b890b3078eba65f601aeafbcfaca92..0d7e6bfbcb8f33f39b4a40e0dee1f77030046171 100644 (file)
@@ -1480,7 +1480,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
   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::spaceRequiredBetween(const AnnotatedLine &Line,
            ((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;
index bebd8d67d4912b722ea62beb613e88639281c018..b175d2a2ecb04be831fbb7735946b9d87d4a0ca5 100644 (file)
@@ -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"