summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-02-08 09:52:54 +0000
committerDaniel Jasper <djasper@google.com>2016-02-08 09:52:54 +0000
commit2a9f720129b8fcd9ffedf27cc2201e3f4e186ec7 (patch)
treedf7979b8596e24cbc663ad9be012e3ca97bfbf7a
parent08a70542b117610199aadc3c352049ea43b03632 (diff)
downloadbcm5719-llvm-2a9f720129b8fcd9ffedf27cc2201e3f4e186ec7.tar.gz
bcm5719-llvm-2a9f720129b8fcd9ffedf27cc2201e3f4e186ec7.zip
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
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp5
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 1e2946f0b01..1c721ff6520 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 0db5d9c89a1..8d541301a33 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;
OpenPOWER on IntegriCloud