From: Daniel Jasper Date: Wed, 3 Jun 2015 09:26:03 +0000 (+0000) Subject: clang-format: Properly reset BreakBeforeParameter when wrapping X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e690f7c5c154bd291030480c55664fe84ca3023;p=clang clang-format: Properly reset BreakBeforeParameter when wrapping operators to the new line. Before: LOG_IF(aaa == // bbb) << a << b; After: LOG_IF(aaa == // bbb) << a << b; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238911 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 204bcc9df4..10a716c551 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -463,6 +463,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, if (NextNonComment->is(tok::question) || (PreviousNonComment && PreviousNonComment->is(tok::question))) State.Stack.back().BreakBeforeParameter = true; + if (Current.is(TT_BinaryOperator) && Current.CanBreakBefore) + State.Stack.back().BreakBeforeParameter = false; if (!DryRun) { unsigned Newlines = std::max( diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 09e514e7cd..69d6cee7de 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4965,6 +4965,9 @@ TEST_F(FormatTest, AlignsPipes) { " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaa)\n" " << aaaaaaaaaaaaaaaaaaaaaaaaaa;"); + verifyFormat("LOG_IF(aaa == //\n" + " bbb)\n" + " << a << b;"); // Breaking before the first "<<" is generally not desirable. verifyFormat(