clang-format: Slightly row back on r256343 by increasing penalty for

breaking between array subscripts.

Before:
  if (aaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaa]
                                                     [aaaaaaaaaaaaa])
After:
  if (aaaaaaaaaaaaaaaaaaaaaaaa &&
      aaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaa][aaaaaaaaaaaaa])

llvm-svn: 256640
This commit is contained in:
Daniel Jasper 2015-12-30 12:23:00 +00:00
parent 113438cd5c
commit e1afb9b8ee
2 changed files with 5 additions and 1 deletions

View File

@ -1715,8 +1715,10 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
Right.Next->is(TT_DictLiteral)))
return 1;
if (Right.is(tok::l_square)) {
if (Style.Language == FormatStyle::LK_Proto || Left.is(tok::r_square))
if (Style.Language == FormatStyle::LK_Proto)
return 1;
if (Left.is(tok::r_square))
return 25;
// Slightly prefer formatting local lambda definitions like functions.
if (Right.is(TT_LambdaLSquare) && Left.is(tok::equal))
return 50;

View File

@ -6047,6 +6047,8 @@ TEST_F(FormatTest, FormatsArrays) {
" [bbbbbbbbbbbbbbbbbbbbbbbbb] = c;");
verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaa(aaaaaaaaaaaa)]\n"
" [bbbbbbbbbbb(bbbbbbbbbbbb)] = c;");
verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaa &&\n"
" aaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaa][aaaaaaaaaaaaa]) {\n}");
verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" [bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = ccccccccccc;");
verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"