]> granicus.if.org Git - clang/commitdiff
clang-format: Fix regression caused by r237244.
authorDaniel Jasper <djasper@google.com>
Tue, 19 May 2015 11:06:33 +0000 (11:06 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 19 May 2015 11:06:33 +0000 (11:06 +0000)
Before:
  [call aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.
          aaaaaaaa];

After:
  [call aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa
          .aaaaaaaa];

This merely papers over the fact that we aren't parsing ObjC method calls
correctly. Also, the indentation is weird.

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

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

index f4b2f00655636e8f6ef27a161403d512d4c137e3..d3122615c83cd525a1d2450133f81fe92deaad12 100644 (file)
@@ -2132,7 +2132,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
     return true;
   if (Right.is(TT_SelectorName) || (Right.is(tok::identifier) && Right.Next &&
                                     Right.Next->is(TT_ObjCMethodExpr)))
-    return true;
+    return Left.isNot(tok::period); // FIXME: Properly parse ObjC calls.
   if (Left.is(tok::r_paren) && Line.Type == LT_ObjCProperty)
     return true;
   if (Left.ClosesTemplateDeclaration)
index ab09e0075d646fbe205a2cd3b0f192e8dbe7aae3..3903ac31e83a69bbf688bd643de76dc23bb7decd 100644 (file)
@@ -7340,6 +7340,9 @@ TEST_F(FormatTest, FormatObjCMethodExpr) {
                "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa];");
   verifyFormat("[aaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaa[aaaaaaaaaaaaaaaaaaaaa]\n"
                "    aaaaaaaaaaaaaaaaaaaaaa];");
+  verifyFormat("[call aaaaaaaa.aaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa.aaaaaaaa\n"
+               "        .aaaaaaaa];", // FIXME: Indentation seems off.
+               getLLVMStyleWithColumns(60));
 
   verifyFormat(
       "scoped_nsobject<NSTextField> message(\n"