r200405 - clang-format: Fix formatting of custom proto options.
Daniel Jasper
djasper at google.com
Wed Jan 29 10:43:40 PST 2014
Author: djasper
Date: Wed Jan 29 12:43:40 2014
New Revision: 200405
URL: http://llvm.org/viewvc/llvm-project?rev=200405&view=rev
Log:
clang-format: Fix formatting of custom proto options.
Before:
repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {
aaaaaaaaaaaaaaaaa : AAAAAAAA
}];
After:
repeated double value = 1
[(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaaa : AAAAAAAA}];
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=200405&r1=200404&r2=200405&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Jan 29 12:43:40 2014
@@ -1469,7 +1469,7 @@ bool TokenAnnotator::mustBreakBefore(con
// deliberate choice and might have aligned the contents of the string
// literal accordingly. Thus, we try keep existing line breaks.
return Right.NewlinesBefore > 0;
- } else if (Right.Previous->is(tok::l_brace) &&
+ } 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.
return true;
Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=200405&r1=200404&r2=200405&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Wed Jan 29 12:43:40 2014
@@ -80,6 +80,8 @@ TEST_F(FormatTestProto, MessageFieldAttr
" deprecated = true];");
verifyFormat("optional LongMessageType long_proto_field = 1\n"
" [default = REALLY_REALLY_LONG_CONSTANT_VALUE];");
+ verifyFormat("repeated double value = 1\n"
+ " [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaaa : AAAAAAAA}];");
}
TEST_F(FormatTestProto, FormatsOptions) {
More information about the cfe-commits
mailing list