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 <class SomeType, class SomeOtherType>
SomeType
SomeFunction(SomeType Type, SomeOtherType OtherType) {}

After:
template <class SomeType, class SomeOtherType>
SomeType SomeFunction(SomeType Type, SomeOtherType OtherType) {}

This fixes llvm.org/PR16072.

llvm-svn: 182457
This commit is contained in:
Daniel Jasper 2013-05-22 08:55:55 +00:00
parent 8410a867eb
commit 53e8d854fd
2 changed files with 5 additions and 1 deletions

View File

@ -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;

View File

@ -2077,6 +2077,10 @@ TEST_F(FormatTest, FormatsOneParameterPerLineIfNecessary) {
" .aaaaaaa();\n"
"}",
NoBinPacking);
verifyFormat(
"template <class SomeType, class SomeOtherType>\n"
"SomeType SomeFunction(SomeType Type, SomeOtherType OtherType) {}",
NoBinPacking);
}
TEST_F(FormatTest, FormatsBuilderPattern) {