Skip to content

Commit 03ca006

Browse files
committed
Update release notes, fixup UnwrappedLineFormatter
1 parent 7604f55 commit 03ca006

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,11 @@ clang-format
543543
- Add ``NumericLiteralCase`` option for enforcing character case in numeric
544544
literals.
545545
- Add ``Leave`` suboption to ``IndentPPDirectives``.
546+
<<<<<<< HEAD
546547
- Add ``AllowBreakBeforeQtProperty`` option.
548+
=======
549+
- Add ``AllowShortRecordOnASingleLine`` option and set it to ``EmptyIfAttached`` for LLVM style.
550+
>>>>>>> 47fe17fb9e64 (Update release notes, fixup UnwrappedLineFormatter)
547551

548552
libclang
549553
--------

clang/lib/Format/UnwrappedLineFormatter.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ class LineJoiner {
500500
: 0;
501501
}
502502

503-
const bool TryMergeShortRecord = [&]() {
503+
auto TryMergeShortRecord = [&]() {
504504
switch (Style.AllowShortRecordOnASingleLine) {
505505
case FormatStyle::SRS_Never:
506506
return false;
@@ -510,7 +510,7 @@ class LineJoiner {
510510
case FormatStyle::SRS_Always:
511511
return true;
512512
}
513-
}() && !Style.BraceWrapping.SplitEmptyRecord;
513+
};
514514

515515
if (TheLine->Last->is(tok::l_brace)) {
516516
bool ShouldMerge = false;
@@ -525,7 +525,9 @@ class LineJoiner {
525525
// NOTE: We use AfterClass (whereas AfterStruct exists) for both
526526
// classes and structs, but it seems that wrapping is still handled
527527
// correctly elsewhere.
528-
ShouldMerge = !Style.BraceWrapping.AfterClass || TryMergeShortRecord;
528+
ShouldMerge =
529+
!Style.BraceWrapping.AfterClass ||
530+
(TryMergeShortRecord() && !Style.BraceWrapping.SplitEmptyRecord);
529531
}
530532
} else if (TheLine->InPPDirective ||
531533
!TheLine->First->isOneOf(tok::kw_class, tok::kw_enum,
@@ -959,12 +961,12 @@ class LineJoiner {
959961
Limit -= 2;
960962
unsigned MergedLines = 0;
961963

962-
bool TryMergeBlock =
964+
const bool TryMergeBlock =
963965
Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never;
964-
bool TryMergeRecord =
966+
const bool TryMergeRecord =
965967
Style.AllowShortRecordOnASingleLine == FormatStyle::SRS_Always;
966-
bool NextIsEmptyBlock = I[1]->First == I[1]->Last && I + 2 != E &&
967-
I[2]->First->is(tok::r_brace);
968+
const bool NextIsEmptyBlock = I[1]->First == I[1]->Last && I + 2 != E &&
969+
I[2]->First->is(tok::r_brace);
968970

969971
if (TryMergeBlock || TryMergeRecord || NextIsEmptyBlock) {
970972
MergedLines = tryMergeSimpleBlock(I + 1, E, Limit);

0 commit comments

Comments
 (0)