<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62117>62117</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] `AllowShortBlocksOnASingleLine: Empty` does not allow short blocks on single lines
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
thebear8
</td>
</tr>
</table>
<pre>
clang-format version: 16.0.0 on Windows 10
`AllowShortBlocksOnASingleLine: Empty` behaves like `AllowShortBlocksOnASingleLine: Never` for empty blocks.
Minimal Example:
Config:
```yaml
---
BasedOnStyle: Chromium
AllowShortBlocksOnASingleLine: Empty
BreakBeforeBraces: Custom
BraceWrapping:
AfterControlStatement: Always
AfterFunction: true
...
```
Yields this:
```c++
#include <iostream>
int main(int argc, char* argv[])
{
while (true)
{
}
while (true)
{
std::cout << "ASDAJKSDGJKASDGJAGSDJHAGSDKJGASJKDHGAKJHSDGJKHASGD";
}
}
```
Setting `AllowShortBlocksOnASingleLine` to `Always` results in correct formatting:
```c++
#include <iostream>
int main(int argc, char* argv[])
{
while (true) {}
while (true)
{
std::cout << "ASDAJKSDGJKASDGJAGSDJHAGSDKJGASJKDHGAKJHSDGJKHASGD";
}
}
```
I noticed this while working on a very large project, so I tried to boil it down as much as possible.
Using `AllowShortBlocksOnASingleLine: Always` isn't really feaisble because I only want empty blocks to be on a single line.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVU-PuzYQ_TTmMgoCkyXkwIGEze4mbX8HVP3UozETcNfYkW2S5ttXhmRD_0hNT62EbMee9zJvZuxh1opWIebkZUNeyoANrtMmdx3WyEwW1Lq55lwy1S6O2vTMwRmNFVqRpIA4DaMwAq3gu1CNvliIIxKVJCpuYxoVUupL1WnjNlLzT_tNFZVQrcQfhELP8dqf3JWkEdTYsTNakOIT4RnkT3hG45FHbQA9DdSjZTj34UehR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