summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 38086379fe7..5a3dee63870 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -609,6 +609,18 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
std::max(std::max(State.Column, NewParenState.Indent),
State.Stack.back().LastSpace);
+ // Don't allow the RHS of an operator to be split over multiple lines unless
+ // there is a line-break right after the operator.
+ // Exclude relational operators, as there, it is always more desirable to
+ // have the LHS 'left' of the RHS.
+ // FIXME: Implement this for '<<' and BreakBeforeBinaryOperators.
+ if (!Newline && Previous && Previous->Type == TT_BinaryOperator &&
+ !Previous->isOneOf(tok::lessless, tok::question, tok::colon) &&
+ Previous->getPrecedence() > prec::Assignment &&
+ Previous->getPrecedence() != prec::Relational &&
+ !Style.BreakBeforeBinaryOperators)
+ NewParenState.NoLineBreak = true;
+
// Do not indent relative to the fake parentheses inserted for "." or "->".
// This is a special case to make the following to statements consistent:
// OuterFunction(InnerFunctionCall( // break
OpenPOWER on IntegriCloud