Fix line-breaking problem caused by comment.

Before, clang-format would not find a solution for formatting:
if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
     bbbbbbbbbbbbbbbbbb) && // aaaaaaaaaaaaaaaa
    cccccc) {
}

llvm-svn: 183096
This commit is contained in:
Daniel Jasper 2013-06-03 08:42:05 +00:00
parent 2d18790b3a
commit 68d888cfed
2 changed files with 5 additions and 0 deletions

View File

@ -1040,6 +1040,7 @@ private:
// should also break after the operator.
if (Previous.Type == TT_BinaryOperator &&
Current.Type != TT_BinaryOperator && // Special case for ">>".
!Current.isTrailingComment() &&
!Previous.isOneOf(tok::lessless, tok::question) &&
Previous.getPrecedence() != prec::Assignment &&
State.Stack.back().BreakBeforeParameter)

View File

@ -1991,6 +1991,10 @@ TEST_F(FormatTest, LineBreakingInBinaryExpressions) {
" TheLine.Last->FormatTok.Tok.getLocation()) -\n"
" 1);");
verifyFormat("if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
" bbbbbbbbbbbbbbbbbb) && // aaaaaaaaaaaaaaaa\n"
" cccccc) {\n}");
FormatStyle OnePerLine = getLLVMStyle();
OnePerLine.BinPackParameters = false;
verifyFormat(