]> granicus.if.org Git - clang/commitdiff
clang-format: Fix weird alignment when not aligning after brackets.
authorDaniel Jasper <djasper@google.com>
Mon, 8 Feb 2016 09:52:54 +0000 (09:52 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 8 Feb 2016 09:52:54 +0000 (09:52 +0000)
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

lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTest.cpp

index 1e2946f0b0172043c9ca579003223bbfb216f6af..1c721ff65208488c085a02a88eb122e477123c7b 100644 (file)
@@ -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
index 0db5d9c89a1109b639e1a46afa37d459fa6689f2..8d541301a33bea4d69adbac7a7a8292c09428ee0 100644 (file)
@@ -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;