[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
Thu May 7 14:03:01 PDT 2026
================
@@ -1607,21 +1607,15 @@ TEST_F(FormatTest, FormatShortBracedStatements) {
AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine =
FormatStyle::SIS_Never;
verifyFormat("if (true) {}", AllowSimpleBracedStatements);
- verifyFormat("if (true) {\n"
- " f();\n"
- "}",
- AllowSimpleBracedStatements);
+ verifyFormat("if (true) { f(); }", AllowSimpleBracedStatements);
----------------
rudolflovrencic wrote:
If that's the case, I don't see a way to fix this without deprecating these options and introducing new ones instead of these. I might be missing another way...
FWIW, this is my reasoning for this change:
- With this change, users upgrading to `v23` would be able to keep their previous style by modifying their `.clang-format` file.
- Without this change, some styles that were possible before `v22` are **no longer possible at all**.
Is it not acceptable to do this as part of a major release (`v23`)? I thought that changes to `.clang-format` are sometimes required when upgrading. It seems especially acceptable in this case since `v22` already broke existing behavior.
Adding an extra sentence to the docs in `v23` explaining that these affect only the braceless variants also doen't make this acceptable?
https://github.com/llvm/llvm-project/pull/196021
More information about the cfe-commits
mailing list