]> granicus.if.org Git - clang/commitdiff
Fix function declaration behavior.
authorDaniel Jasper <djasper@google.com>
Wed, 22 May 2013 08:55:55 +0000 (08:55 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 22 May 2013 08:55:55 +0000 (08:55 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182457 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/Format.cpp
unittests/Format/FormatTest.cpp

index dd0ece506420582674aa58777fdd2d7b7f6ca5fa..1f36f9ab64c0212301da9c10bbeb3b98da30eddc 100644 (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;
index 4ffb0d67eb56037a588eeda009e5533d2b8e7566..8c178d6a5c1f05edc14c393a4c0d06fcbf36c5ce 100644 (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) {