[clang] [clang-format] Add option AllowShortRecordsOnASingleLine (PR #154580)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 20 14:45:57 PDT 2025
================
@@ -453,6 +453,19 @@ class LineJoiner {
}
}
+ auto ShouldMergeShortRecords = [this, &I, &NextLine, PreviousLine,
+ TheLine]() {
+ if (Style.AllowShortRecordsOnASingleLine == FormatStyle::SRS_All)
+ return true;
+ if (Style.AllowShortRecordsOnASingleLine == FormatStyle::SRS_Empty &&
+ NextLine.First->is(tok::r_brace)) {
+ return true;
+ }
+ return false;
+ };
+
+ bool MergeShortRecord = ShouldMergeShortRecords();
----------------
HazardyKnusperkeks wrote:
```suggestion
const bool MergeShortRecord = [this, &NextLine]() {
switch (Style.AllowShortRecordsOnASingleLine) {
case FormatStyle::SRS_All: return true;
case FormatStyle::SRS_Empty: return NextLine.First->is(tok::r_brace);
case FormatStyle::SRS_Never: return false;
}
}();
```
https://github.com/llvm/llvm-project/pull/154580
More information about the cfe-commits
mailing list