r176262 - Reduce penalty for splitting after "{" in static initializers.
Daniel Jasper
djasper at google.com
Thu Feb 28 07:04:12 PST 2013
Author: djasper
Date: Thu Feb 28 09:04:12 2013
New Revision: 176262
URL: http://llvm.org/viewvc/llvm-project?rev=176262&view=rev
Log:
Reduce penalty for splitting after "{" in static initializers.
This fixes llvm.org/PR15379.
Before:
const uint8_t aaaaaaaaaaaaaaaaaaaaaa[0] = { 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, // comment
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, // comment
0x00, 0x00, 0x00, 0x00 // comment
};
After:
const uint8_t aaaaaaaaaaaaaaaaaaaaaa[0] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment
0x00, 0x00, 0x00, 0x00 // comment
};
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=176262&r1=176261&r2=176262&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Feb 28 09:04:12 2013
@@ -880,8 +880,6 @@ unsigned TokenAnnotator::splitPenalty(co
else
return 100;
}
- if (Left.is(tok::l_brace) && Right.isNot(tok::l_brace))
- return 50;
if (Left.is(tok::equal) && Right.is(tok::l_brace))
return 150;
if (Left.is(tok::coloncolon))
@@ -917,7 +915,7 @@ unsigned TokenAnnotator::splitPenalty(co
return 20;
if (Left.is(tok::l_paren) || Left.is(tok::l_square) ||
- Left.Type == TT_TemplateOpener)
+ Left.is(tok::l_brace) || Left.Type == TT_TemplateOpener)
return 20;
if (Right.is(tok::lessless)) {
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=176262&r1=176261&r2=176262&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Feb 28 09:04:12 2013
@@ -612,6 +612,11 @@ TEST_F(FormatTest, CommentsInStaticIniti
"\n"
" b\n"
"};"));
+ verifyFormat("const uint8_t aaaaaaaaaaaaaaaaaaaaaa[0] = {\n"
+ " 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment\n"
+ " 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment\n"
+ " 0x00, 0x00, 0x00, 0x00 // comment\n"
+ "};");
}
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list