diff options
author | Daniel Jasper <djasper@google.com> | 2017-03-14 00:40:32 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2017-03-14 00:40:32 +0000 |
commit | c79e4d2d253d234c3f5bef70ab1d5fbb582cd279 (patch) | |
tree | 4cb6f628ac9faacd6226c32ca01a51e54baee80d | |
parent | 54e22f33d9bf2e1225e58d8cb69dad0c64886fcc (diff) | |
download | bcm5719-llvm-c79e4d2d253d234c3f5bef70ab1d5fbb582cd279.tar.gz bcm5719-llvm-c79e4d2d253d234c3f5bef70ab1d5fbb582cd279.zip |
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
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestProto.cpp | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index ed9788d7476..228425bc473 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -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) || diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp index 41d210ac7cd..d174c65a1f3 100644 --- a/clang/unittests/Format/FormatTestProto.cpp +++ b/clang/unittests/Format/FormatTestProto.cpp @@ -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) { |