]> granicus.if.org Git - clang/commitdiff
clang-format: Fix corner case in builder-type calls.
authorDaniel Jasper <djasper@google.com>
Fri, 30 Aug 2013 07:12:40 +0000 (07:12 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 30 Aug 2013 07:12:40 +0000 (07:12 +0000)
Before:
  aaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaa()->aaaaaaaaaaaaaae(
                                                 0)->aaaaaaaaaaaaaaa();

After:
  aaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaa()
      ->aaaaaaaaaaaaaae(0)
      ->aaaaaaaaaaaaaaa();

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

lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTest.cpp

index 718e4a5cdeff8d018b6d5c97b66fb7c38cbd589a..10295197240d104ee066d8176238c8d1fdc7226c 100644 (file)
@@ -187,7 +187,9 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
       State.ParenLevel == 0)
     return true;
   if (startsSegmentOfBuilderTypeCall(Current) &&
-      State.Stack.back().CallContinuation != 0)
+      (State.Stack.back().CallContinuation != 0 ||
+       (State.Stack.back().BreakBeforeParameter &&
+        State.Stack.back().ContainsUnwrappedBuilder)))
     return true;
   return false;
 }
index c5e0bcdb55af2d129ce4d9701f028b4d73535f8b..eee888893032b1b458f01374be838f866ad4a03c 100644 (file)
@@ -2890,6 +2890,9 @@ TEST_F(FormatTest, FormatsBuilderPattern) {
   verifyFormat("aaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa()\n"
                "    .aaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa()\n"
                "    .aaaaaaaaaaaaaaa();");
+  verifyFormat("aaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaa()\n"
+               "    ->aaaaaaaaaaaaaae(0)\n"
+               "    ->aaaaaaaaaaaaaaa();");
 }
 
 TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {