Skip to content

Commit 5e57a10

Browse files
authored
[clang-format] Allow breaking before bit-field colons (#153529)
Fixes #153448
1 parent 9a692e0 commit 5e57a10

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6272,7 +6272,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
62726272
}
62736273

62746274
if (Right.is(tok::colon) &&
6275-
!Right.isOneOf(TT_CtorInitializerColon, TT_InlineASMColon)) {
6275+
!Right.isOneOf(TT_CtorInitializerColon, TT_InlineASMColon,
6276+
TT_BitFieldColon)) {
62766277
return false;
62776278
}
62786279
if (Left.is(tok::colon) && Left.isOneOf(TT_DictLiteral, TT_ObjCMethodExpr)) {

clang/unittests/Format/FormatTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4050,6 +4050,10 @@ TEST_F(FormatTest, FormatsBitfields) {
40504050
" uchar : 8;\n"
40514051
" uchar other;\n"
40524052
"};");
4053+
verifyFormat("struct foo {\n"
4054+
" uint8_t i_am_a_bit_field_this_long\n"
4055+
" : struct_with_constexpr::i_am_a_constexpr_lengthhhhh;\n"
4056+
"};");
40534057
FormatStyle Style = getLLVMStyle();
40544058
Style.BitFieldColonSpacing = FormatStyle::BFCS_None;
40554059
verifyFormat("struct Bitfields {\n"

0 commit comments

Comments
 (0)