diff options
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestProto.cpp | 29 |
3 files changed, 19 insertions, 15 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 4c93c7f548c..82dffd6fff5 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -150,8 +150,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { Previous.Type != TT_InlineASMColon && Previous.Type != TT_ConditionalExpr && nextIsMultilineString(State)) return true; - if (Style.Language != FormatStyle::LK_Proto && - ((Previous.Type == TT_DictLiteral && Previous.is(tok::l_brace)) || + if (((Previous.Type == TT_DictLiteral && Previous.is(tok::l_brace)) || Previous.Type == TT_ArrayInitializerLSquare) && Style.ColumnLimit > 0 && getLengthToMatchingParen(Previous) + State.Column > getColumnLimit(State)) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 18008623ec1..a324d2fa472 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1768,7 +1768,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, return Right.NewlinesBefore > 0; } else if (Right.Previous->is(tok::l_brace) && Right.NestingLevel == 1 && Style.Language == FormatStyle::LK_Proto) { - // Don't enums onto single lines in protocol buffers. + // Don't put enums onto single lines in protocol buffers. return true; } else if (Style.Language == FormatStyle::LK_JavaScript && Right.is(tok::r_brace) && Left.is(tok::l_brace) && diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp index a56feedf80b..3a2f97e875d 100644 --- a/clang/unittests/Format/FormatTestProto.cpp +++ b/clang/unittests/Format/FormatTestProto.cpp @@ -85,16 +85,19 @@ TEST_F(FormatTestProto, MessageFieldAttributes) { " [default = REALLY_REALLY_LONG_CONSTANT_VALUE];"); verifyFormat("repeated double value = 1\n" " [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaaa: AAAAAAAA}];"); - verifyFormat("repeated double value = 1\n" - " [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA,\n" - " bbbbbbbbbbbbbbbb: BBBBBBBBBB}];"); - verifyFormat("repeated double value = 1\n" - " [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA\n" - " bbbbbbbbbbbbbbbb: BBBBBBBBBB}];"); - verifyFormat("repeated double value = 1\n" - " [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA,\n" - " bbbbbbb: BBBB,\n" - " bbbb: BBB}];"); + verifyFormat("repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {\n" + " aaaaaaaaaaaaaaaa: AAAAAAAAAA,\n" + " bbbbbbbbbbbbbbbb: BBBBBBBBBB\n" + "}];"); + verifyFormat("repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {\n" + " aaaaaaaaaaaaaaaa: AAAAAAAAAA\n" + " bbbbbbbbbbbbbbbb: BBBBBBBBBB\n" + "}];"); + verifyFormat("repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {\n" + " aaaaaaaaaaaaaaaa: AAAAAAAAAA,\n" + " bbbbbbb: BBBB,\n" + " bbbb: BBB\n" + "}];"); } TEST_F(FormatTestProto, FormatsOptions) { @@ -109,8 +112,10 @@ TEST_F(FormatTestProto, FormatsOptions) { " field_a: OK\n" " field_b: \"OK\"\n" " field_c: \"OK\"\n" - " msg_field: {field_d: 123\n" - " field_e: OK}\n" + " msg_field: {\n" + " field_d: 123\n" + " field_e: OK\n" + " }\n" "};"); verifyFormat("option (MyProto.options) = {\n" |