From 27e901289bada6a2f97c0d35fd47a2d5dd2d38c4 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 28 Jan 2014 18:51:11 +0000 Subject: [PATCH] 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]; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200327 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 1 + unittests/Format/FormatTestProto.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 17ae49e595..e0f3e57cd7 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/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/unittests/Format/FormatTestProto.cpp b/unittests/Format/FormatTestProto.cpp index 83e003465f..6304d9688f 100644 --- a/unittests/Format/FormatTestProto.cpp +++ b/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];"); } -- 2.40.0