[clang-format] Fix Bug 41407

Differential Revision: https://reviews.llvm.org/D60359

llvm-svn: 357851
This commit is contained in:
Owen Pan 2019-04-06 23:10:11 +00:00
parent bcb29cb748
commit fca07890a9
2 changed files with 8 additions and 1 deletions

View File

@ -1057,7 +1057,7 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
if (Current.is(TT_ProtoExtensionLSquare))
return State.Stack.back().Indent;
if (State.Stack.back().Indent == State.FirstIndent && PreviousNonComment &&
PreviousNonComment->isNot(tok::r_brace))
!PreviousNonComment->isOneOf(tok::r_brace, TT_CtorInitializerComma))
// Ensure that we fall back to the continuation indent width instead of
// just flushing continuations left.
return State.Stack.back().Indent + Style.ContinuationIndentWidth;

View File

@ -11946,6 +11946,13 @@ TEST_F(FormatTest, ConstructorInitializerIndentWidth) {
"bool smaller = 1 < bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);",
Style);
Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
verifyFormat(
"SomeClass::Constructor() :\n"
"aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa),\n"
"aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa) {}",
Style);
}
TEST_F(FormatTest, BreakConstructorInitializersBeforeComma) {