<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/145161>145161</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Add clang-format option for formatting single statement function on one line with braces
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
void2012
</td>
</tr>
</table>
<pre>
Hello! I want to format my C++ code with custom formatting style specified in .clang-format file. The clang-format documentation says there is an option that allows to put short function bodies on the same line with functions.
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#allowshortfunctionsonasingleline
However, this is not what I want. I want the function body braces to be put on the same line with function body itself, not the whole thing with signature.
With `AllowShortFunctionsOnASingleLine: All`:
```cpp
inline const char* GetBuildingName(TTownType townType, type_building_id buildingId) { return FASTCALL_2(const char*, 0x460CC0, townType, buildingId); } // everything on the same line, ugly
```
With `AllowShortFunctionsOnASingleLine: None`:
```cpp
inline const char* GetBuildingName(TTownType townType, type_building_id buildingId)
{
return FASTCALL_2(const char*, 0x460CC0, townType, buildingId); // I need it on the single line
}
```
Desired behavior:
```cpp
inline const char* GetBuildingName(TTownType townType, type_building_id buildingId)
{ return FASTCALL_2(const char*, 0x460CC0, townType, buildingId); } // what I want, but only for single-line body functions
```
It would be also great to have such an option for structs/classes that contain only a single line of code inside their bodies. Thanks!
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVVFr6zgT_TXKy9AgK47TPvjBScl3C-Xehwa-xyLLE1u7smSkcbL-94tkt032wsLCLhcMFmI0c87R6IwMQbcWsWTbPds-r-RInfPlxelG8EysatdM5Tc0xjGRwQtcpSUgB2fne0nQT3BgYs_EHpRrEK6aOlBjINcvIaRtC4EmgxAGVPqssQFtYa2MtO3DkuesDa7h1CHcbTdOjT1akqSdhSCnANShR9ABpAU3pH3qJIE0xl1DhDaMBKFznuA8WpUiatdoDJBiEYLsEYy2C9yPqLAG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