diff options
author | Daniel Jasper <djasper@google.com> | 2016-06-23 09:40:19 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2016-06-23 09:40:19 +0000 |
commit | 7f3b99fca7f21e3dfde40f376d27ff769adda8d8 (patch) | |
tree | ea4913bf614043ae7656b3d387c22c699504812b /clang | |
parent | e6ca7b6a6b1a979f5d48b294e5a047ed68467b63 (diff) | |
download | bcm5719-llvm-7f3b99fca7f21e3dfde40f376d27ff769adda8d8.tar.gz bcm5719-llvm-7f3b99fca7f21e3dfde40f376d27ff769adda8d8.zip |
clang-format: [Proto] Use more compact format for text-formatted options
Before:
enum Type {
UNKNOWN = 0 [(some_options) = {
a: aa,
b: bb
}];
};
After:
enum Type {
UNKNOWN = 0 [(some_options) = {a: aa, b: bb}];
};
llvm-svn: 273553
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestProto.cpp | 10 |
2 files changed, 5 insertions, 8 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 9c4a6268abe..664be6fb40e 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2332,9 +2332,6 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, return (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) || (Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) || (Line.startsWith(tok::kw_struct) && Style.BraceWrapping.AfterStruct); - if (Style.Language == FormatStyle::LK_Proto && Left.isNot(tok::l_brace) && - Right.is(TT_SelectorName)) - return true; if (Left.is(TT_ObjCBlockLBrace) && !Style.AllowShortBlocksOnASingleLine) return true; diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp index 2580f7fb8c0..d9fb1409139 100644 --- a/clang/unittests/Format/FormatTestProto.cpp +++ b/clang/unittests/Format/FormatTestProto.cpp @@ -74,8 +74,11 @@ TEST_F(FormatTestProto, FormatsEnums) { " TYPE_B = 2;\n" "};"); verifyFormat("enum Type {\n" + " UNKNOWN = 0 [(some_options) = {a: aa, b: bb}];\n" + "};"); + verifyFormat("enum Type {\n" " UNKNOWN = 0 [(some_options) = {\n" - " a: aa,\n" + " a: aa, // wrap\n" " b: bb\n" " }];\n" "};"); @@ -153,10 +156,7 @@ TEST_F(FormatTestProto, FormatsOptions) { " field_a: OK\n" " field_b: \"OK\"\n" " field_c: \"OK\"\n" - " msg_field: {\n" - " field_d: 123\n" - " field_e: OK\n" - " }\n" + " msg_field: {field_d: 123 field_e: OK}\n" "};"); verifyFormat("option (MyProto.options) = {\n" " field_a: OK // Comment\n" |