Issue 101631
Summary [clang-format] AllowShortBlocksOnASingleLine discards whole format settings (in C)
Labels clang-format
Assignees
Reporter alexveden
    I came across a weid bug when introducing ` AllowShortBlocksOnASingleLine ` into config discards almost all .clang-format settings, including indentation.

.clang-format
```
---
Language: Cpp
BasedOnStyle:  Mozilla
IndentWidth:     4
# AllowShortBlocksOnASingleLine: never
...

```

This is a format without  " AllowShortBlocksOnASingleLine: never" enabled.
```c

int
foo(int x)
{
    for (int i = 0; i < x; i++) {
        x += i;
    }
    return x;
}

```

After enabling, the whole thing looks different:
* Indent now 2 instead of 4
* int before foo() not at the new line
* `{` after foo() not at the new line
```c
int foo(int x) {
  for (int i = 0; i < x; i++) {
    x += i;
  }
  return x;
}

```


Clang-format version: 18.1.8

I've found this when I tried `AllowShortBlocksOnASingleLine: always` but it seems that value doesn't matter, just a presence of this parameter breaks things.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to