The clang-format
BreakBeforeBraces: Custom
# if true this allows if (a) { return; } to be put on a single line.
AllowShortBlocksOnASingleLine: Always
# If true, if (a) return; can be put on a single line.
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
BraceWrapping:
AfterControlStatement: Always
BeforeElse: true
produces different result on clang-format-20 vs clang-format-21 and the version 21 appears to be incorrect.
It appears that the AfterControlStatement: Always is ignored in clang-format-21
The else block below has a different in brace-wrapping
// with clang-format-20
int foo() {
int bar = 0;
int verylooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongvar;
if (bar) { return bar; }
else
{
return verylooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongvar;
}
}
// with clang-format-21
int foo() {
int bar = 0;
int verylooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongvar;
if (bar) { return bar; }
else {
return verylooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongvar;
}
}