]> granicus.if.org Git - clang/commitdiff
clang-format: Fix indentation in multi-line placement new.
authorDaniel Jasper <djasper@google.com>
Wed, 6 Aug 2014 13:14:58 +0000 (13:14 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 6 Aug 2014 13:14:58 +0000 (13:14 +0000)
Before:
  auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
      new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))
      typename aaaaaaaaaaaaaaaaaaaaaaaa();

After:
  auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
      new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))
          typename aaaaaaaaaaaaaaaaaaaaaaaa();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214964 91177308-0d34-0410-b5e6-96231b3b80d8

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

index ea68150d6a4294062ebed223c33dae31c4c165e8..9088de23571eccd37b2d40ab0fb21d9f9cf1212f 100644 (file)
@@ -561,6 +561,9 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
     return State.FirstIndent + Style.ConstructorInitializerIndentWidth;
   if (NextNonComment->Type == TT_CtorInitializerComma)
     return State.Stack.back().Indent;
+  if (Previous.is(tok::r_paren) && !Current.isBinaryOperator() &&
+      Current.isNot(tok::colon))
+    return ContinuationIndent;
   if (State.Stack.back().Indent == State.FirstIndent && PreviousNonComment &&
       PreviousNonComment->isNot(tok::r_brace))
     // Ensure that we fall back to the continuation indent width instead of
index 6bbda9d6e3bd1e8a8405127b86c33baae37806d8..5c526c12e12c1e50b5685a4adc67af3292326642 100644 (file)
@@ -4729,6 +4729,9 @@ TEST_F(FormatTest, UnderstandsNewAndDelete) {
                "}");
   verifyFormat("new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))\n"
                "    typename aaaaaaaaaaaaaaaaaaaaaaaa();");
+  verifyFormat("auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n"
+               "    new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))\n"
+               "        typename aaaaaaaaaaaaaaaaaaaaaaaa();");
 }
 
 TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {