[PATCH] D67395: [clang-format] Apply BAS_AlwaysBreak to C++11 braced lists
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 10 16:25:34 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371571: [clang-format] Apply BAS_AlwaysBreak to C++11 braced lists (authored by owenpan, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D67395?vs=219528&id=219626#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67395/new/
https://reviews.llvm.org/D67395
Files:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -7835,6 +7835,16 @@
"};",
NoBinPacking);
+ NoBinPacking.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+ EXPECT_EQ("static uint8 CddDp83848Reg[] = {\n"
+ " CDDDP83848_BMCR_REGISTER,\n"
+ " CDDDP83848_BMSR_REGISTER,\n"
+ " CDDDP83848_RBR_REGISTER};",
+ format("static uint8 CddDp83848Reg[] = {CDDDP83848_BMCR_REGISTER,\n"
+ " CDDDP83848_BMSR_REGISTER,\n"
+ " CDDDP83848_RBR_REGISTER};",
+ NoBinPacking));
+
// FIXME: The alignment of these trailing comments might be bad. Then again,
// this might be utterly useless in real code.
verifyFormat("Constructor::Constructor()\n"
Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -606,7 +606,9 @@
// disallowing any further line breaks if there is no line break after the
// opening parenthesis. Don't break if it doesn't conserve columns.
if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak &&
- Previous.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) &&
+ (Previous.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) ||
+ (Previous.is(tok::l_brace) && Previous.BlockKind != BK_Block &&
+ Style.Cpp11BracedListStyle)) &&
State.Column > getNewLineColumn(State) &&
(!Previous.Previous || !Previous.Previous->isOneOf(
tok::kw_for, tok::kw_while, tok::kw_switch)) &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67395.219626.patch
Type: text/x-patch
Size: 1903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190910/ed47962f/attachment.bin>
More information about the cfe-commits
mailing list