diff options
| author | Daniel Jasper <djasper@google.com> | 2014-01-28 18:51:11 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-01-28 18:51:11 +0000 |
| commit | a0e9be2bb26c6a4976cff771a78257b5d9b1cb7f (patch) | |
| tree | 9b41f7d3151f8f9e5136713b6253849b8811cd1b | |
| parent | 5fdb09bb765127b8afdb8b245109d12b4bf311d2 (diff) | |
| download | bcm5719-llvm-a0e9be2bb26c6a4976cff771a78257b5d9b1cb7f.tar.gz bcm5719-llvm-a0e9be2bb26c6a4976cff771a78257b5d9b1cb7f.zip | |
clang-format: Fix option formatting in protocol buffer files.
Before:
optional int32 foo[ default = true, deprecated = true ];
After:
optional int32 foo[default = true, deprecated = true];
llvm-svn: 200327
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 1 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTestProto.cpp | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 17ae49e595d..e0f3e57cd76 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -248,6 +248,7 @@ private: if (CurrentToken->is(tok::colon)) ColonFound = true; if (CurrentToken->is(tok::comma) && + Style.Language != FormatStyle::LK_Proto && (Left->Type == TT_ArraySubscriptLSquare || (Left->Type == TT_ObjCMethodExpr && !ColonFound))) Left->Type = TT_ArrayInitializerLSquare; diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp index 83e003465fa..6304d9688fd 100644 --- a/clang/unittests/Format/FormatTestProto.cpp +++ b/clang/unittests/Format/FormatTestProto.cpp @@ -74,6 +74,10 @@ TEST_F(FormatTestProto, UnderstandsReturns) { TEST_F(FormatTestProto, MessageFieldAttributes) { verifyFormat("optional string test = 1 [default = \"test\"];"); + verifyFormat("optional bool a = 1 [default = true, deprecated = true];"); + verifyFormat("optional LongMessageType long_proto_field = 1\n" + " [default = REALLY_REALLY_LONG_CONSTANT_VALUE,\n" + " deprecated = true];"); verifyFormat("optional LongMessageType long_proto_field = 1\n" " [default = REALLY_REALLY_LONG_CONSTANT_VALUE];"); } |

