From: Daniel Jasper Date: Fri, 30 Aug 2013 07:12:40 +0000 (+0000) Subject: clang-format: Fix corner case in builder-type calls. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb331832830c51322a225a3de480189c7d6d7503;p=clang clang-format: Fix corner case in builder-type calls. 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 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 718e4a5cde..1029519724 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -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; } diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index c5e0bcdb55..eee8888930 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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) {