[clang] [clang-format] Add option AllowShortRecordOnASingleLine (PR #154580)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 24 14:59:15 PDT 2025
=?utf-8?q?Tomáš?= Slanina <itzexpoexpo at gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoexpo at gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoexpo at gmail.com>,
=?utf-8?q?Tomáš?= Slanina <itzexpoexpo at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/154580 at github.com>
owenca wrote:
> > ...
> >
> > * `Never`
> >
> > ```c++
> > class foo {
> > };
> >
> > class bar {
> > int i;
> > };
> > ```
> > Am I correct?
>
> Yes, except `Never` then depends on `SplitEmptyRecord` and is therefore also affected by #154796.
The command-line option `-style='{AllowShortRecordsOnASingleLine: Never}'` I used in the example implies `AfterClass: false`, so `SplitEmptyRecord` doesn't matter. See https://github.com/llvm/llvm-project/issues/154796#issuecomment-3218392876.
> If you use `AfterClass: true` you get the correct behavior:
>
> ```
> $ clang-format -style="{AllowShortRecordsOnASingleLine: Empty, BraceWrapping: {AfterClass: true}, BreakBeforeBraces: Custom}" a.cpp
> class foo {};
`SplitEmptyRecord: true`, which is effective here, should override `AllowShortRecordsOnASingleLine` for empty records.
https://github.com/llvm/llvm-project/pull/154580
More information about the cfe-commits
mailing list