From: Daniel Jasper Date: Thu, 19 Dec 2013 16:06:40 +0000 (+0000) Subject: clang-format: Slightly adapt decision of when to break before <<. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c75c5e64f6537be3dea5725c0d0fcf55d4943ac1;p=clang clang-format: Slightly adapt decision of when to break before <<. Before: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaa); After: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaa); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197690 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index c840c4557f..366d26d479 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -338,7 +338,7 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, // short. Also always add the penalty if the LHS is split over mutliple lines // to avoid unncessary line breaks that just work around this penalty. if (Current.is(tok::lessless) && State.Stack.back().FirstLessLess == 0 && - (State.Column <= Style.ColumnLimit / 2 || + (State.Column <= Style.ColumnLimit / 3 || State.Stack.back().BreakBeforeParameter)) Penalty += Style.PenaltyBreakFirstLessLess; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 7d58ec2ed9..db105ee323 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3800,6 +3800,8 @@ TEST_F(FormatTest, AlignsPipes) { getLLVMStyleWithColumns(70)); // But sometimes, breaking before the first "<<" is desirable. + verifyFormat("Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa)\n" + " << aaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaa);"); verifyFormat("Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)\n" " << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" " << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;");