<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/101631>101631</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] AllowShortBlocksOnASingleLine discards whole format settings (in C)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
alexveden
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE1v4zgM_TXKhYjhyM6HDz7kAwEKzGIOXWDPskXbnMpSINFJu79-IdszTYrFdNDAUGRT1CP5yKdCoNYilmJ9EOvTQg3cOV8qg69X1GgXldNv5RPUqkdQtXchgIIbkoZqaOHWoQWy7J0earItiE0Ke2Pc7blzng_G1S_hu90_k20NfiOL4wmy7KB2tqEWNIVaeR1Amd4FBmUMJLVRtl02zveKISAz2TYIeQSytRl0RCKr0bJicjYR6Umk-2l98J0Nm3R-xtflcjltvinbDqpFke3heLlMHw8qoP5un_nNjAb4y_1LxqjJ-jSi_kOau9EIAPkMIrPfZx7PW7yin-NMHsL-EOO0_t1RAIoVn0txI-7cwABCyj9FkxLQqsqgTj5A1fdYZOdqNc4JuSPL8CpkMR_ZHqZNTLhxHuYTBCI7QSqyw7g9wuu4FfIwPgU8OMbfK0RLdgIS2Z1JbE_vLx558Ha86yf86dNa7RtGP2VKto29wh3CrXMGgbvYMca5lwCamgY9WhbZz-vkHiZewbobSCAbGJUG17yTu49NCxU2ziNMJYr5WcegeISyeAMTK__LI0a4PcSGV2Nwf-L2gZsI-kjIfUm_zMT_snDHwZcYmNbj_ehe0QdyNjbjapeskt39yScht9dYzMHqSFGY5OQJ2BPqWL1PO1yZm3oLscLVwEBRK7APwF3EVmZA0A6DFXLL0CvmOA5H-DFEnYGLx4C2xsjzCH9RXvUYmao8qpcw9U2Yx2ahy0wXWaEWWK62Uq53m22eLbqyUWtZb9Jsg4WqsKnyKterVVNjtk0zlekFlTKVebpLZbpbFWmWYKFRq0bjrpCY57XIU-wVmcSYa5843y4ohAHLVbraZKuFURWaMEq0lA_yJmUUbV9Gv2U1tEHkqaHA4f0mJjajvD84rk-fyPQvWZ4m6IMUT10HRyGLxeBN2TFfQhwoeRby3BJ3Q5XUrhfyHAOZ_5YX735gzUKex_yCkOc5xWsp_wsAAP__Shn0ng">