Skip to content

Commit f464367

Browse files
committed
Fix missing empty block check
1 parent 1346788 commit f464367

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

clang/lib/Format/UnwrappedLineFormatter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ class LineJoiner {
647647
Line->Last->is(tok::l_brace) && NextLine->First->is(tok::r_brace);
648648

649649
if ((IsEmptyBlock && !Style.BraceWrapping.SplitEmptyRecord) ||
650-
Style.AllowShortBlocksOnASingleLine == FormatStyle::SBS_Always) {
650+
(!IsEmptyBlock &&
651+
Style.AllowShortBlocksOnASingleLine == FormatStyle::SBS_Always)) {
651652
return tryMergeSimpleBlock(I, E, Limit);
652653
}
653654
}

clang/unittests/Format/FormatTest.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15410,7 +15410,11 @@ TEST_F(FormatTest, AllowShortRecordOnASingleLine) {
1541015410
"{ int i; };",
1541115411
Style);
1541215412
Style.AllowShortRecordOnASingleLine = FormatStyle::SRS_Always;
15413-
verifyFormat("class foo { int i; };", Style);
15413+
verifyFormat("class foo\n"
15414+
"{\n"
15415+
"};\n"
15416+
"class foo { int i; };",
15417+
Style);
1541415418
}
1541515419

1541615420
TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {

0 commit comments

Comments
 (0)