clang-format: Fix incorrect line break in certain configurations.

Before:
  void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa,
                          vector<int>
                              bbbbbbbbbbbbbbb);

After:
  void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa,
                          vector<int> bbbbbbbbbbbbbbb);

llvm-svn: 257257
This commit is contained in:
Daniel Jasper 2016-01-09 15:56:47 +00:00
parent 804a276fcf
commit 00693b08cf
2 changed files with 6 additions and 1 deletions

View File

@ -150,7 +150,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
return true;
if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
(Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName)) ||
(Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
Previous.NestingLevel == 1) ||
(Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) &&
Previous.isNot(tok::question)) ||
(!Style.BreakBeforeTernaryOperators &&

View File

@ -4062,6 +4062,10 @@ TEST_F(FormatTest, FormatsDeclarationsOnePerLine) {
" int aaaaaaaaaaaaaaaaaaaa,\n"
" int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}",
NoBinPacking);
NoBinPacking.AllowAllParametersOfDeclarationOnNextLine = false;
verifyFormat("void aaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" vector<int> bbbbbbbbbbbbbbb);",
NoBinPacking);
}
TEST_F(FormatTest, FormatsOneParameterPerLineIfNecessary) {