diff options
author | Daniel Jasper <djasper@google.com> | 2014-04-17 11:32:02 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-04-17 11:32:02 +0000 |
commit | ae8e0d8da9de8eb1cf81fb0e24e9dfda43957aab (patch) | |
tree | 1753879a942ff6413f244be8c6e2998397bfa38e /clang/lib | |
parent | 057fa3a5a5cab738b4fe14d440df25b0440fa6e8 (diff) | |
download | bcm5719-llvm-ae8e0d8da9de8eb1cf81fb0e24e9dfda43957aab.tar.gz bcm5719-llvm-ae8e0d8da9de8eb1cf81fb0e24e9dfda43957aab.zip |
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
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Format/FormatToken.cpp | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 52ee47987f1..de2047c458f 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -725,6 +725,7 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State, AvoidBinPacking = Current.BlockKind == BK_Block || Current.Type == TT_ArrayInitializerLSquare || Current.Type == TT_DictLiteral || + !Style.BinPackParameters || (NextNoComment && NextNoComment->Type == TT_DesignatedInitializerPeriod); } else { 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<bool, 8> MustBreakBeforeItem; |