<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54933>54933</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format inconsistently breaks short while loops without braces (AllowShortBlocksOnASingleLine: Empty)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
HunterKohler
</td>
</tr>
</table>
<pre>
When enabling `AllowShortBlocksOnASingleLine` with the `Empty` value, clang-format does the following with short, braced loops:
### Input
```c
int main()
{
while(cond()) {
}
}
```
### Output
```c
int main()
{
while (cond()) {}
}
```
Alternatively, for while loops without braces, the formatting goes as follows:
### Input
```c
int main()
{
while (cond());
}
```
### Input
```c
int main()
{
while (my_cond())
;
}
```
Though not in everyone's taste, this does seem to violate the purpose of the `Empty` option.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1U02P0zAQ_TXOxdoqtfPRHHJoKRUIpD0sEkdkJ5PErGNHttOq_x7baWHLrhYQEFmJP15mnt_M47o9158HUBgU41KoHqMi3UqpTw-DNm4ndfNo79X2wR9J-CgU-HN8Em7AboAAfjtO7hw2j0zOgMgb3Eim-rtOm5E53GqwEdrpEDVkiH_bED6guWENtFhqPVlEtyjdo_T6JnQZ-L2aZnfZLNJlNMtaKIdHJhQiG0SqC6bcLRPsn9MgpOe1abRqLyBS4RvIk1m5v4bY_5TvZWb3s_tLavhFbr_HYysdGMWcOII8BzW96peoUdCotZ7dorINiKUWoTYuFKMP9WH2Up7_WIFn10R092dS_xMK4_nLLYvvkFj-X3H65NXsB6y0w8Kb5gjmrL0nSOmbnFkHi8LCLn1vAUbsND4KLZmDqP00m0lbwLp75iA9OaHV6ub28Z20NW0rWrHECSehvnGYUP5CVvjkysmzrzSwR7v465VWCFq87nO6xQszUiWzkfXg3OJQcvCj99Fmvmr06BdSHq-fu8nor9B4ax-EtXPouUOeVZQmQ92xqk2brks5lBmBbsMLTiiUOW87TmmWSMZB2hrlO0SIghOOIfwc5ftE1CQlJM3W-TpPy_V6RfOM8KIEBgUUzSZFWQq-CeQq8Fhp0yemjpT43Ft_KL1G9schs1b0CiCm8_HZ7PUx9btZeU990IMEk8T8deT_DcD_fy8">