summaryrefslogtreecommitdiffstats
path: root/lib/Format/FormatToken.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-12-19 08:40:56 +0000
committerDaniel Jasper <djasper@google.com>2016-12-19 08:40:56 +0000
commit895b5f639a673c8189c984d3c26c9237950257be (patch)
tree037b8863dc36a2475b0ced680bf58e4c75b680d5 /lib/Format/FormatToken.cpp
parent70a217a797bf1c9566b86398aa90dc970f8aee20 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290090 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/FormatToken.cpp')
-rw-r--r--lib/Format/FormatToken.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Format/FormatToken.cpp b/lib/Format/FormatToken.cpp
index e0dfac7d4e..b51f807ccc 100644
--- a/lib/Format/FormatToken.cpp
+++ b/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.