Fix expression breaking for one-parameter-per-line styles.

Before:
  if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
After:
  if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181828 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Jasper 2013-05-14 20:39:56 +00:00
Родитель 6e01994046
Коммит d741f02da9
2 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -543,7 +543,8 @@ private:
if (State.Stack.back().AvoidBinPacking) {
// If we are breaking after '(', '{', '<', this is not bin packing
// unless AllowAllParametersOfDeclarationOnNextLine is false.
if ((Previous.isNot(tok::l_paren) && Previous.isNot(tok::l_brace)) ||
if (!(Previous.isOneOf(tok::l_paren, tok::l_brace) ||
Previous.Type == TT_BinaryOperator) ||
(!Style.AllowAllParametersOfDeclarationOnNextLine &&
Line.MustBeDeclaration))
State.Stack.back().BreakBeforeParameter = true;

Просмотреть файл

@ -1646,6 +1646,14 @@ TEST_F(FormatTest, LineBreakingInBinaryExpressions) {
" SourceMgr.getSpellingColumnNumber(\n"
" TheLine.Last->FormatTok.Tok.getLocation()) -\n"
" 1);");
FormatStyle OnePerLine = getLLVMStyle();
OnePerLine.BinPackParameters = false;
verifyFormat(
"if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n}",
OnePerLine);
}
TEST_F(FormatTest, ExpressionIndentation) {