From 5962fa80c2c41f5d467ff362f9a1db3abf243539 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 3 Jun 2015 09:26:03 +0000 Subject: [PATCH] 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; llvm-svn: 238911 --- clang/lib/Format/ContinuationIndenter.cpp | 2 ++ clang/unittests/Format/FormatTest.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 204bcc9d..10a716c 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 09e514e..69d6cee 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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( -- 2.7.4