[clang] [clang-format] Disable short blocks if brace is on the new line (PR #196021)
Rudolf Lovrenčić via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 13 07:36:52 PDT 2026
================
@@ -895,6 +889,11 @@ class LineJoiner {
Line.startsWithExportBlock()) {
if (IsSplitBlock)
return 0;
+ // The construct-specific options AllowShortIfStatementsOnASingleLine and
+ // AllowShortLoopsOnASingleLine take precedence over
+ // AllowShortBlocksOnASingleLine: a statement whose specific option
+ // disallows merging is not put on a single line even when short blocks
+ // are always allowed.
----------------
rudolflovrencic wrote:
> Note that 2 and 3 are indeed "overriding" AllowShortLoopsOnASingleLine in some sense. I think these are all as intended, and the changes here will cause more regressions.
Why do you think that this is intended? To me, it makes more sense that a more specific option should be applied over the more generic one. In example 2, `AllowShortLoopsOnASingleLine: true` has no effect.
> ...it's not clear how to support users through a transition.
Transition `21 -> 22` made some styles no longer possible. This change aims to re-enable these (#183705, #187993). Some users will have to change their `.clang-format` files in order to keep their style, but they should be able to achieve the same style as before. Do you have some style that is no longer possible to achive with this change?
https://github.com/llvm/llvm-project/pull/196021
More information about the cfe-commits
mailing list