From 2a9f720129b8fcd9ffedf27cc2201e3f4e186ec7 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 8 Feb 2016 09:52:54 +0000 Subject: [PATCH] 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. llvm-svn: 260080 --- clang/lib/Format/ContinuationIndenter.cpp | 3 ++- clang/unittests/Format/FormatTest.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 1e2946f..1c721ff 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 0db5d9c..8d54130 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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; -- 2.7.4