diff options
| author | Daniel Jasper <djasper@google.com> | 2016-12-19 08:40:56 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2016-12-19 08:40:56 +0000 |
| commit | ff8d61369b181ede3c313c85feb39e0a402d0e38 (patch) | |
| tree | e6e075a3c283a14600c9aef56e780c8abad04b34 | |
| parent | 1fd41963375f1af42b3df896f5df9010fe08fa9f (diff) | |
| download | bcm5719-llvm-ff8d61369b181ede3c313c85feb39e0a402d0e38.tar.gz bcm5719-llvm-ff8d61369b181ede3c313c85feb39e0a402d0e38.zip | |
clang-format: Fix regression introduced in r290084.
We still want to try in linewrap within single elements of a 1-column
list.
After:
Type *Params[] = {PointerType::getUnqual(FunctionType::get(
Builder.getVoidTy(), Builder.getInt8PtrTy(), false)),
Builder.getInt8PtrTy(),
Builder.getInt32Ty(),
LongType,
LongType,
LongType};
Before:
No line break in the first element, so column limit violation.
llvm-svn: 290090
| -rw-r--r-- | clang/lib/Format/FormatToken.cpp | 8 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp index e0dfac7d4e1..b51f807ccc1 100644 --- a/clang/lib/Format/FormatToken.cpp +++ b/clang/lib/Format/FormatToken.cpp @@ -92,6 +92,14 @@ unsigned CommaSeparatedList::formatAfterToken(LineState &State, // Find the best ColumnFormat, i.e. the best number of columns to use. const ColumnFormat *Format = getColumnFormat(RemainingCodePoints); + + // Formatting with 1 Column isn't really a column layout, so we don't need the + // special logic here. We can just avoid bin packing any of the parameters. + if (Format && Format->Columns == 1) { + State.Stack.back().AvoidBinPacking = true; + return 0; + } + // If no ColumnFormat can be used, the braced list would generally be // bin-packed. Add a severe penalty to this so that column layouts are // preferred if possible. diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 70abf3af7d7..9c2c25d0910 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -6641,7 +6641,7 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) { "std::this_thread::sleep_for(\n" " std::chrono::nanoseconds{ std::chrono::seconds{ 1 } } / 5);", ExtraSpaces); - verifyFormat("std::vector<MyValues> aaaaaaaaaaaaaaaaaaa{\n" + verifyFormat("std::vector<MyValues> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{\n" " aaaaaaa,\n" " aaaaaaaaaa,\n" " aaaaa,\n" |

