[clang] [clang-format] Disable short blocks if brace is on the new line (PR #196021)
Gedare Bloom via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 16 07:07:00 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.
----------------
gedare wrote:
> If I follow your logic correctly about which option is responsible for which part of functions/statements, this looks like the cleanest approach. But, after reading "[justify additional style options docs](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options)", I don't have "_a publicly accessible style guide_" nor is this style "_used in a project of significant size (have dozens of contributors)_". So, it's your call if you want to have this option or we are ending it here. There is also middle ground of just having `AllowShortBlocksOnASingleLine.Attached` which would make a difference for me.
That decision would be up to @HazardyKnusperkeks and @mydeveloperday. It does seem to me that adding the `AllowShortBlocksOnASingleLine.Attached` option will be the right way to fix the regression though.
https://github.com/llvm/llvm-project/pull/196021
More information about the cfe-commits
mailing list