r190209 - clang-format: Fix regression introduced by r190038.
Daniel Jasper
djasper at google.com
Fri Sep 6 14:46:42 PDT 2013
Author: djasper
Date: Fri Sep 6 16:46:41 2013
New Revision: 190209
URL: http://llvm.org/viewvc/llvm-project?rev=190209&view=rev
Log:
clang-format: Fix regression introduced by r190038.
Before:
Constructor()
: aaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {
}
After:
Constructor()
: aaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {
}
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=190209&r1=190208&r2=190209&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Fri Sep 6 16:46:41 2013
@@ -225,7 +225,12 @@ unsigned ContinuationIndenter::addTokenT
Penalty += Style.PenaltyBreakFirstLessLess;
if (Current.is(tok::r_brace)) {
- State.Column = State.Stack[State.Stack.size() - 2].LastSpace;
+ if (Current.MatchingParen &&
+ (Current.MatchingParen->BlockKind == BK_BracedInit ||
+ !Current.MatchingParen->Children.empty()))
+ State.Column = State.Stack[State.Stack.size() - 2].LastSpace;
+ else
+ State.Column = State.FirstIndent;
} else if (Current.is(tok::string_literal) &&
State.StartOfStringLiteral != 0) {
State.Column = State.StartOfStringLiteral;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=190209&r1=190208&r2=190209&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Sep 6 16:46:41 2013
@@ -2495,6 +2495,10 @@ TEST_F(FormatTest, ConstructorInitialize
verifyFormat("Constructor(int Parameter = 0)\n"
" : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}");
+ verifyFormat("Constructor()\n"
+ " : aaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {\n"
+ "}",
+ getLLVMStyleWithColumns(60));
// Here a line could be saved by splitting the second initializer onto two
// lines, but that is not desireable.
More information about the cfe-commits
mailing list