From ae8e0d8da9de8eb1cf81fb0e24e9dfda43957aab Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 17 Apr 2014 11:32:02 +0000 Subject: clang-format: Respect BinPackParameters in Cpp11BracedListStyle. With BinPackParameters=false and Cpp11BracedListStyle=true (i.e. mostly for Chromium): Before: const Aaaaaa aaaaa = {aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk}; After: const Aaaaaa aaaaa = {aaaaa, bbbbb, ccccc, ddddd, eeeee, ffffff, ggggg, hhhhhh, iiiiii, jjjjjj, kkkkkk}; This fixes llvm.org/PR19359. I am not sure we'll want this in all cases in the long run, but I'll guess we'll get feedback on that. llvm-svn: 206458 --- clang/lib/Format/FormatToken.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'clang/lib/Format/FormatToken.cpp') diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp index c147dbb6b1b..a7c003bc18a 100644 --- a/clang/lib/Format/FormatToken.cpp +++ b/clang/lib/Format/FormatToken.cpp @@ -132,6 +132,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) + return; + FormatToken *ItemBegin = Token->Next; SmallVector MustBreakBeforeItem; -- cgit v1.2.3