Skip to content

Commit fca0789

Browse files
committed
[clang-format] Fix Bug 41407
Differential Revision: https://reviews.llvm.org/D60359 llvm-svn: 357851
1 parent bcb29cb commit fca0789

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
10571057
if (Current.is(TT_ProtoExtensionLSquare))
10581058
return State.Stack.back().Indent;
10591059
if (State.Stack.back().Indent == State.FirstIndent && PreviousNonComment &&
1060-
PreviousNonComment->isNot(tok::r_brace))
1060+
!PreviousNonComment->isOneOf(tok::r_brace, TT_CtorInitializerComma))
10611061
// Ensure that we fall back to the continuation indent width instead of
10621062
// just flushing continuations left.
10631063
return State.Stack.back().Indent + Style.ContinuationIndentWidth;

clang/unittests/Format/FormatTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11946,6 +11946,13 @@ TEST_F(FormatTest, ConstructorInitializerIndentWidth) {
1194611946
"bool smaller = 1 < bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n"
1194711947
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);",
1194811948
Style);
11949+
11950+
Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
11951+
verifyFormat(
11952+
"SomeClass::Constructor() :\n"
11953+
"aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa),\n"
11954+
"aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa) {}",
11955+
Style);
1194911956
}
1195011957

1195111958
TEST_F(FormatTest, BreakConstructorInitializersBeforeComma) {

0 commit comments

Comments
 (0)