From: Daniel Jasper Date: Mon, 8 Feb 2016 09:52:54 +0000 (+0000) Subject: clang-format: Fix weird alignment when not aligning after brackets. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7bb97b213b5337c6c5cafefa2f452d0c23730e75;p=clang clang-format: Fix weird alignment when not aligning after brackets. Before: bbbbbbbbbbbb(aaaaaaaaaaaaaaaaaaaaaaaa, // ccccccc(aaaaaaaaaaaaaaaaa, // b)); After: bbbbbbbbbbbb(aaaaaaaaaaaaaaaaaaaaaaaa, // ccccccc(aaaaaaaaaaaaaaaaa, // b)); This fixes llvm.org/PR24905. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260080 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 1e2946f0b0..1c721ff652 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -863,7 +863,8 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State, // ParameterToInnerFunction)); if (*I > prec::Unknown) NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column); - if (*I != prec::Conditional && !Current.is(TT_UnaryOperator)) + if (*I != prec::Conditional && !Current.is(TT_UnaryOperator) && + Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign) NewParenState.StartOfFunctionCall = State.Column; // Always indent conditional expressions. Never indent expression where diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 0db5d9c89a..8d541301a3 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4434,6 +4434,11 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) { " aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa));", Style); + verifyFormat("bbbbbbbbbbbb(aaaaaaaaaaaaaaaaaaaaaaaa, //\n" + " ccccccc(aaaaaaaaaaaaaaaaa, //\n" + " b));", + Style); + Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak; Style.BinPackArguments = false; Style.BinPackParameters = false;