From: Daniel Jasper Date: Wed, 6 Aug 2014 13:14:58 +0000 (+0000) Subject: clang-format: Fix indentation in multi-line placement new. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b7401235ec2cb54577367b46dc7974e44b76761;p=clang clang-format: Fix indentation in multi-line placement new. 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 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index ea68150d6a..9088de2357 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -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 diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 6bbda9d6e3..5c526c12e1 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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) {