From ead41b6b8fa50d93bc21cad2c8d195dcfc7cb9cb Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 28 Feb 2013 09:39:12 +0000 Subject: [PATCH] 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) {} llvm-svn: 176242 --- clang/lib/Format/Format.cpp | 3 ++- clang/unittests/Format/FormatTest.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index ea96b8f..e3f7b4b 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -654,7 +654,8 @@ private: 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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 81833e5..929e3c2 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1173,6 +1173,13 @@ TEST_F(FormatTest, ConstructorInitializers) { " 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; -- 2.7.4