From 359a05461d132b1e2d74655cad1a01ace6f654e5 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 6 Apr 2019 23:10:11 +0000 Subject: [PATCH] [clang-format] Fix Bug 41407 Differential Revision: https://reviews.llvm.org/D60359 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@357851 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/ContinuationIndenter.cpp | 2 +- unittests/Format/FormatTest.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index b64fdd7c0b..577d96d52c 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -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; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 110d60a5a8..dc2512a9e2 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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) { -- 2.40.0