Issue 160775
Summary [clang-format] Regression in `BraceWrapping` after else block with `AllowShortBlocksOnASingleLine` and `AllowShortIfStatementsOnASingleLine`
Labels clang-format
Assignees
Reporter shyun3
    `.clang-format`:
```yaml
AllowShortBlocksOnASingleLine: Always
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
BraceWrapping:
 AfterControlStatement: Always
  BeforeElse: true
BreakBeforeBraces: Custom
```

`test.cpp`:
```cpp
int main() {
  int x = 1;
  if (x > 0)
  {
    ++x;
    --x;
  }
  else
  {
    --x;
    ++x;
 }
}
```

Expected result of running `clang-format`: no change

Actual result:
```cpp
int main() {
  int x = 1;
  if (x > 0)
  {
    ++x;
 --x;
  }
  else {
    --x;
    ++x;
  }
}
```

Note how the brace after the `else` on line 8 has not been wrapped despite the block not being "short".

This seems to occur beginning at version 21.1.0. Version 20.1.8 yields the expected result.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to