r260080 - clang-format: Fix weird alignment when not aligning after brackets.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 8 01:52:54 PST 2016
Author: djasper
Date: Mon Feb 8 03:52:54 2016
New Revision: 260080
URL: http://llvm.org/viewvc/llvm-project?rev=260080&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=260080&r1=260079&r2=260080&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Feb 8 03:52:54 2016
@@ -863,7 +863,8 @@ void ContinuationIndenter::moveStatePast
// 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
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=260080&r1=260079&r2=260080&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Feb 8 03:52:54 2016
@@ -4434,6 +4434,11 @@ TEST_F(FormatTest, AlignsAfterOpenBracke
" aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa));",
Style);
+ verifyFormat("bbbbbbbbbbbb(aaaaaaaaaaaaaaaaaaaaaaaa, //\n"
+ " ccccccc(aaaaaaaaaaaaaaaaa, //\n"
+ " b));",
+ Style);
+
Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
Style.BinPackArguments = false;
Style.BinPackParameters = false;
More information about the cfe-commits
mailing list