From: Daniel Jasper Date: Fri, 14 Nov 2014 13:14:45 +0000 (+0000) Subject: clang-format: Improve function parameter packing. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=277674854c973b60a03753ce1473986aa42c9c27;p=clang clang-format: Improve function parameter packing. Before: void SomeLoooooooooooongFunction( std::unique_ptr aaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbb); After: void SomeLoooooooooooongFunction( std::unique_ptr aaaaaaaaaaaaaaaaaaaaaaaaaa, int bbbbbbbbbbbbb); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221989 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 7fdc1af09b..c8dbd962e8 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -464,7 +464,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, if (PreviousNonComment && !PreviousNonComment->isOneOf(tok::comma, tok::semi) && - PreviousNonComment->Type != TT_TemplateCloser && + (PreviousNonComment->Type != TT_TemplateCloser || + Current.NestingLevel != 0) && PreviousNonComment->Type != TT_BinaryOperator && PreviousNonComment->Type != TT_JavaAnnotation && PreviousNonComment->Type != TT_LeadingJavaAnnotation && diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 0510871a05..31984f6bfa 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3541,6 +3541,10 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) { " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " bbbb bbbb);"); + verifyFormat("void SomeLoooooooooooongFunction(\n" + " std::unique_ptr\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaa,\n" + " int bbbbbbbbbbbbb);"); // Treat overloaded operators like other functions. verifyFormat("SomeLoooooooooooooooooooooooooogType\n"