]> granicus.if.org Git - clang/commitdiff
Revert "[clang-format] Fix putting ObjC message arguments in one line for multiline...
authorJacek Olesiak <jolesiak@google.com>
Tue, 22 May 2018 16:44:42 +0000 (16:44 +0000)
committerJacek Olesiak <jolesiak@google.com>
Tue, 22 May 2018 16:44:42 +0000 (16:44 +0000)
Summary: Reverts D46879

Reviewers: benhamilton

Reviewed By: benhamilton

Subscribers: krasimir, klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D47205

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

lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTestObjC.cpp

index fe6a956839641d80275766bedb7660e969e53dea..441df05a52d38334c234768390608d0d02f3cbab 100644 (file)
@@ -1073,34 +1073,8 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
   if (Current.isMemberAccess())
     State.Stack.back().StartOfFunctionCall =
         !Current.NextOperator ? 0 : State.Column;
-  if (Current.is(TT_SelectorName) &&
-      !State.Stack.back().ObjCSelectorNameFound) {
+  if (Current.is(TT_SelectorName))
     State.Stack.back().ObjCSelectorNameFound = true;
-
-    // Reevaluate whether ObjC message arguments fit into one line.
-    // If a receiver spans multiple lines, e.g.:
-    //   [[object block:^{
-    //     return 42;
-    //   }] a:42 b:42];
-    // BreakBeforeParameter is calculated based on an incorrect assumption
-    // (it is checked whether the whole expression fits into one line without
-    // considering a line break inside a message receiver).
-    if (Current.Previous && Current.Previous->closesScope() &&
-        Current.Previous->MatchingParen &&
-        Current.Previous->MatchingParen->Previous) {
-      const FormatToken &CurrentScopeOpener =
-          *Current.Previous->MatchingParen->Previous;
-      if (CurrentScopeOpener.is(TT_ObjCMethodExpr) &&
-          CurrentScopeOpener.MatchingParen) {
-        int NecessarySpaceInLine =
-            getLengthToMatchingParen(CurrentScopeOpener, State.Stack) +
-            CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
-        if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
-            Style.ColumnLimit)
-          State.Stack.back().BreakBeforeParameter = false;
-      }
-    }
-  }
   if (Current.is(TT_CtorInitializerColon) &&
       Style.BreakConstructorInitializers != FormatStyle::BCIS_AfterColon) {
     // Indent 2 from the column, so:
index 92b2fc0557a61e87ecf208aa137c7006aaa7c248..c29c9d702bc9691ad020b60f49c4b977aa805638 100644 (file)
@@ -796,35 +796,6 @@ TEST_F(FormatTestObjC, FormatObjCMethodExpr) {
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
-  // Message receiver taking multiple lines.
-  Style.ColumnLimit = 20;
-  // Non-corner case.
-  verifyFormat("[[object block:^{\n"
-               "  return 42;\n"
-               "}] a:42 b:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object block:^{\n"
-               "  return 42;\n"
-               "}] aaaaaaa:42 b:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object block:^{\n"
-               "  return 42;\n"
-               "}] aaaaaaa:42\n"
-               "        bb:42];");
-  // Non-corner case.
-  verifyFormat("[[object aaa:42\n"
-               "           b:42]\n"
-               "    cc:42 d:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object aaa:42\n"
-               "           b:42]\n"
-               "    cccccc:42 d:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object aaa:42\n"
-               "           b:42]\n"
-               "    cccccc:42\n"
-               "        dd:42];");
-
   Style.ColumnLimit = 70;
   verifyFormat(
       "void f() {\n"