[clang] [clang-format] Add option AllowShortRecordOnASingleLine (PR #154580)

via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 24 17:28:41 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>,
=?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:

> > The command-line option `-style='{AllowShortRecordsOnASingleLine: Never}'` I used in the example implies `AfterClass: false`, so `SplitEmptyRecord` doesn't matter. See [#154796 (comment)](https://github.com/llvm/llvm-project/issues/154796#issuecomment-3218392876).
> 
> The same code that merges the brace for `SplitEmptyRecord` does the same for `AllowShortRecordOnASingleLine` since `Never` is treated as "option ignored", changing it so that the behavior is overriden means with the default config you'd get:
> 
> ```c++
> struct foo {
> };
> ```
> 
> from your comment I understood this behavior is not to be changed?

See https://github.com/llvm/llvm-project/pull/154580/files#r2296871961. The default (i.e. the LLVM style) of `AllowShortRecordOnASingleLine` sould be `Empty`.

> > `SplitEmptyRecord: true`, which is effective here, should override `AllowShortRecordsOnASingleLine` for empty records.
> 
> Right, so is the expected behavior this:
> 
> ```c++
> $ clang-format -style="{AllowShortRecordsOnASingleLine: Empty, BraceWrapping: {AfterClass: true}, BreakBeforeBraces: Custom}" a.cpp
> struct foo
> {
> };
> ```
> 
> i.e. should `SplitEmptyRecord: true` mean that `AllowShortRecordOnASingleLine` is effectively ignored? Just checking if I understand correctly.

Yep!

https://github.com/llvm/llvm-project/pull/154580


More information about the cfe-commits mailing list