Issue 162552
Summary [clang-format] if-else single line block formatting wrong on clang-format-21 (inconsistent with version 20)
Labels clang-format
Assignees
Reporter ankurvdev
    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

```c++
// with clang-format-20
int foo() {
  int bar = 0;
  int verylooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongvar;
 if (bar) { return bar; }
  else 
  {
    return verylooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongvar;
 }
}
```

```c++
// with clang-format-21
int foo() {
  int bar = 0;
 int verylooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongvar;
 if (bar) { return bar; }
  else {
    return verylooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongvar;
 }
}

```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to