r230627 - clang-format: Make braced list formatting more consistent.
Daniel Jasper
djasper at google.com
Thu Feb 26 03:46:29 PST 2015
Author: djasper
Date: Thu Feb 26 05:46:29 2015
New Revision: 230627
URL: http://llvm.org/viewvc/llvm-project?rev=230627&view=rev
Log:
clang-format: Make braced list formatting more consistent.
Before:
Aaaa aaaaaaaaaaa{
{
a, // +1 indent weird.
b, // trailing comma signals one per line.
}, // trailing comma signals one per line.
};
After:
Aaaa aaaaaaaaaaa{
{
a, // better!?
b, // trailing comma signals one per line.
}, // trailing comma signals one per line.
};
Interesting that this apparently was entirely untested :-(.
Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=230627&r1=230626&r2=230627&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Feb 26 05:46:29 2015
@@ -824,7 +824,6 @@ void ContinuationIndenter::moveStatePast
++NewIndentLevel;
} else {
NewIndent = State.Stack.back().LastSpace + Style.ContinuationIndentWidth;
- NewIndent = std::min(State.Column + 1, NewIndent);
}
const FormatToken *NextNoComment = Current.getNextNonComment();
AvoidBinPacking =
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=230627&r1=230626&r2=230627&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Feb 26 05:46:29 2015
@@ -5943,6 +5943,11 @@ TEST_F(FormatTest, LayoutCxx11BraceIniti
verifyFormat("std::vector<int> v = {1, 0 /* comment */};");
verifyFormat("Node n{1, Node{1000}, //\n"
" 2};");
+ verifyFormat("Aaaa aaaaaaa{\n"
+ " {\n"
+ " aaaa,\n"
+ " },\n"
+ "};");
// In combination with BinPackParameters = false.
FormatStyle NoBinPacking = getLLVMStyle();
More information about the cfe-commits
mailing list