owenpan created this revision.
owenpan added reviewers: sammccall, MyDeveloperDay, klimek.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
owenpan added a reviewer: djasper.
See PR18455 <https://bugs.llvm.org/show_bug.cgi?id=18455> and this message
<https://lists.llvm.org/pipermail/cfe-dev/2019-September/063246.html>.
Repository:
rC Clang
https://reviews.llvm.org/D67395
Files:
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/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: clang/lib/Format/ContinuationIndenter.cpp
===================================================================
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/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))
&&
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/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: clang/lib/Format/ContinuationIndenter.cpp
===================================================================
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/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)) &&
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits