clang-format: Correctly apply wrap before multi-line RHS rule to

ternary expressions.

Before:
  return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaa : bbbbbbbbbbbbbbb +
							     cccccccccccccccc;

After:
  return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ?
	     aaaaa :
	     bbbbbbbbbbbbbbb + cccccccccccccccc;

llvm-svn: 262293
This commit is contained in:
Daniel Jasper 2016-03-01 04:19:59 +00:00
parent f9168de892
commit 04b4e10873
2 changed files with 5 additions and 1 deletions

View File

@ -847,7 +847,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
// 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.
if (Previous && Previous->getPrecedence() > prec::Assignment &&
if (Previous && Previous->getPrecedence() != prec::Assignment &&
Previous->isOneOf(TT_BinaryOperator, TT_ConditionalExpr) &&
Previous->getPrecedence() != prec::Relational) {
bool BreakBeforeOperator =

View File

@ -4708,6 +4708,10 @@ TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
" /*bbbbbbbbbbbbbbb=*/bbbbbbbbbbbbbbbbbbbbbbbbb :\n"
" ccccccccccccccccccccccccccc;",
Style);
verifyFormat("return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ?\n"
" aaaaa :\n"
" bbbbbbbbbbbbbbb + cccccccccccccccc;",
Style);
}
TEST_F(FormatTest, DeclarationsOfMultipleVariables) {