[clang] [clang-format] Add KwBreakBeforeCaseLabel (PR #227668)
Anan Yablonko via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 2 03:58:03 PDT 2026
ananski-the-3rd wrote:
> `Allow` is something I want to get rid of. `CompactCaseLabels` would be okay. How about `CaseLabelsAndPreceedingBreakOnTheSameLine` wordy is not a problem, in my eyes.
I prefer CompactCaseLabels. It's easy to remember and avoids double-meaning of `break`.
> cppfront does not fulfill (even if it had a style guide) the criteria, even a Herb Sutter only counts as one person.
Agreed that cppfront doesn't quite meet the bar.
> A simple `[[fallthrough]]` does better stand out. On that matter, how should that look like with the proposed option?
I come from C, so I hadn't considered this attribute. As a reader of C++ I'd prefer:
```cpp
switch (*c) {
break; case 'a':
foo();
[[fallthrough]]; case 'b':
bar();
break; default:
baz();
}
```
That isn't implemented yet. Currently it formats as:
```cpp
switch (*c) {
break; case 'a':
foo();
[[fallthrough]]; // or a fallthrough comment in C
case 'b':
bar();
break; default:
baz();
}
```
Which is also readable in my eyes. I can add the first version if you'd like.
> The current proposal comes into a range, where I could accept it, while I currently can't guarantee a merge, working on it is also not definitely wasted time.
I hope so.
Thanks,
Anan
https://github.com/llvm/llvm-project/pull/227668
More information about the cfe-commits
mailing list