diff options
author | Daniel Jasper <djasper@google.com> | 2014-08-13 08:46:21 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-08-13 08:46:21 +0000 |
commit | fef3e209a68a1c28cc9e8d118a022f16e94bc055 (patch) | |
tree | 4a097c0e9b345b17b07cc52b26f12e980ab0b4d9 /lib/Format/FormatToken.cpp | |
parent | 3ed303aa18ac57a8ba38e7bd50a8cd3e48fecbc1 (diff) |
clang-format: Format long lists in columns if without bin-packing.
After (even with BinPacking = false):
const Aaaaaa aaaaa = {
aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh,
iiiiii, jjjjjj, kkkkkk, aaaaa, bbbbb, ccccc, ddddd, eeeee,
ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk,
};
Before:
<each element on its own line>
This fixes http://llvm.org/PR20623.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215529 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/FormatToken.cpp')
-rw-r--r-- | lib/Format/FormatToken.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Format/FormatToken.cpp b/lib/Format/FormatToken.cpp index c91d25f46d..c6f23a6c28 100644 --- a/lib/Format/FormatToken.cpp +++ b/lib/Format/FormatToken.cpp @@ -131,9 +131,11 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) { if (!Token->MatchingParen || Token->isNot(tok::l_brace)) return; - // In C++11 braced list style, we should not format in columns unless we allow - // bin-packing of function parameters. - if (Style.Cpp11BracedListStyle && !Style.BinPackParameters) + // In C++11 braced list style, we should not format in columns unless they + // have many items (20 or more) or we allow bin-packing of function + // parameters. + if (Style.Cpp11BracedListStyle && !Style.BinPackParameters && + Commas.size() < 19) return; FormatToken *ItemBegin = Token->Next; |