From 316ab38ed82dfdcd673be2675e61704478fb8917 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 6 Aug 2014 13:14:58 +0000 Subject: 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(); llvm-svn: 214964 --- clang/lib/Format/ContinuationIndenter.cpp | 3 +++ clang/unittests/Format/FormatTest.cpp | 3 +++ 2 files changed, 6 insertions(+) (limited to 'clang') diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index ea68150d6a4..9088de23571 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 6bbda9d6e3b..5c526c12e12 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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) { -- cgit v1.2.1