Fix incorrect recognition of bin-packing.
Before (in Google style):
Constructor()
: aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(
aaaaaa) {}
After:
Constructor()
: aaaaa(aaaaaa),
aaaaa(aaaaaa),
aaaaa(aaaaaa),
aaaaa(aaaaaa),
aaaaa(aaaaaa) {}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176242 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index ea96b8f..e3f7b4b 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -654,7 +654,8 @@
AvoidBinPacking = false;
} else {
NewIndent = 4 + State.Stack.back().LastSpace;
- AvoidBinPacking = !Style.BinPackParameters;
+ AvoidBinPacking =
+ !Style.BinPackParameters || State.Stack.back().AvoidBinPacking;
}
State.Stack.push_back(
ParenState(NewIndent, State.Stack.back().LastSpace, AvoidBinPacking,
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 81833e5..929e3c2 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1173,6 +1173,13 @@
" some_other_var_(var + 1) { // lined up\n"
"}",
OnePerLine);
+ verifyFormat("Constructor()\n"
+ " : aaaaa(aaaaaa),\n"
+ " aaaaa(aaaaaa),\n"
+ " aaaaa(aaaaaa),\n"
+ " aaaaa(aaaaaa),\n"
+ " aaaaa(aaaaaa) {}",
+ OnePerLine);
// This test takes VERY long when memoization is broken.
OnePerLine.BinPackParameters = false;