Skip to content

Commit b2b5f91

Browse files
committed
Minor fixes for tryMergeRecord
1 parent 73cdd98 commit b2b5f91

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

clang/lib/Format/UnwrappedLineFormatter.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "FormatToken.h"
1111
#include "NamespaceEndCommentsFixer.h"
1212
#include "WhitespaceManager.h"
13+
#include "clang/Basic/TokenKinds.h"
1314
#include "llvm/Support/Debug.h"
1415
#include <queue>
1516

@@ -586,8 +587,8 @@ class LineJoiner {
586587
const auto *Line = I[0];
587588
const auto *NextLine = I[1];
588589

589-
auto GetRelevantAfterOption = [&](const FormatToken *tok) {
590-
switch (tok->getType()) {
590+
auto GetRelevantAfterOption = [&](const FormatToken *Tok) {
591+
switch (Tok->getType()) {
591592
case TT_StructLBrace:
592593
return Style.BraceWrapping.AfterStruct;
593594
case TT_ClassLBrace:
@@ -620,8 +621,12 @@ class LineJoiner {
620621
// Current line begins record, next line block.
621622
if (NextLine->First->isOneOf(TT_StructLBrace, TT_ClassLBrace,
622623
TT_UnionLBrace)) {
623-
if (NextLine->First == NextLine->Last && I + 2 != E &&
624-
I[2]->First->isNot(tok::r_brace) &&
624+
if (I + 2 == E)
625+
return 0;
626+
627+
const bool IsEmptyBlock = I[2]->First->is(tok::r_brace);
628+
629+
if (!IsEmptyBlock &&
625630
Style.AllowShortRecordOnASingleLine == FormatStyle::SRS_Always) {
626631
return tryMergeSimpleBlock(I, E, Limit);
627632
}

0 commit comments

Comments
 (0)