From 24e19e4f96abd12f3f4b72b8a315b8ac257bc88f Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 22 May 2013 08:55:55 +0000 Subject: [PATCH] Fix function declaration behavior. This only affects styles that prevent bin packing. There, a break after a template declaration also forced a line break after the function name. Before: template SomeType SomeFunction(SomeType Type, SomeOtherType OtherType) {} After: template SomeType SomeFunction(SomeType Type, SomeOtherType OtherType) {} This fixes llvm.org/PR16072. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182457 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/Format.cpp | 2 +- unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index dd0ece5064..1f36f9ab64 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -251,7 +251,7 @@ public: State.Column = FirstIndent; State.NextToken = &RootToken; State.Stack.push_back( - ParenState(FirstIndent, FirstIndent, !Style.BinPackParameters, + ParenState(FirstIndent, FirstIndent, /*AvoidBinPacking=*/ false, /*NoLineBreak=*/ false)); State.LineContainsContinuedForLoopSection = false; State.ParenLevel = 0; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 4ffb0d67eb..8c178d6a5c 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -2077,6 +2077,10 @@ TEST_F(FormatTest, FormatsOneParameterPerLineIfNecessary) { " .aaaaaaa();\n" "}", NoBinPacking); + verifyFormat( + "template \n" + "SomeType SomeFunction(SomeType Type, SomeOtherType OtherType) {}", + NoBinPacking); } TEST_F(FormatTest, FormatsBuilderPattern) { -- 2.40.0