clang-format: Make it very slighly more expensive to wrap between "= {".

This prevents unwanted fallout from r296664. Specifically in proto formatting,
this changed:
  optional Aaaaaaaa aaaaaaaa = 12 [
    (aaa) = aaaa,
    (bbbbbbbbbbbbbbbbbbbbbbbbbb) = {
      aaaaaaaaaaaaaaaaa: true,
      aaaaaaaaaaaaaaaa: true
    }
  ];

Into:
  optional Aaaaaaaa aaaaaaaa = 12 [
    (aaa) = aaaa,
    (bbbbbbbbbbbbbbbbbbbbbbbbbb) =
        {aaaaaaaaaaaaaaaaa: true, aaaaaaaaaaaaaaaa: true}
  ];

Which is considered less readable. Generally, it seems preferable to
format such dict literals as blocks rather than contract them to one
line.

llvm-svn: 297696
This commit is contained in:
Daniel Jasper 2017-03-14 00:40:32 +00:00
parent 54e22f33d9
commit c79e4d2d25
2 changed files with 8 additions and 1 deletions

View File

@ -1976,7 +1976,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
if (Right.is(TT_LambdaArrow))
return 110;
if (Left.is(tok::equal) && Right.is(tok::l_brace))
return 150;
return 160;
if (Left.is(TT_CastRParen))
return 100;
if (Left.is(tok::coloncolon) ||

View File

@ -138,6 +138,13 @@ TEST_F(FormatTestProto, MessageFieldAttributes) {
verifyFormat("optional string test = 1 [default =\n"
" \"test\"\n"
" \"test\"];");
verifyFormat("optional Aaaaaaaa aaaaaaaa = 12 [\n"
" (aaa) = aaaa,\n"
" (bbbbbbbbbbbbbbbbbbbbbbbbbb) = {\n"
" aaaaaaaaaaaaaaaaa: true,\n"
" aaaaaaaaaaaaaaaa: true\n"
" }\n"
"];");
}
TEST_F(FormatTestProto, DoesntWrapFileOptions) {