<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61980>61980</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format: strange forced new line
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
alejandroclaro
</td>
</tr>
</table>
<pre>
At least in recent clang-format version (>= 15), clang-format is inserting a strange newline before any function definition. For example:
```c++
// clang-format off
static const int MATRIX[3][3] =
{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
};
// clang-format on
/**
* @brief Does something.
*/
static void
doFoo()
{
}
```
is forced into
```c++
// clang-format off
static const int MATRIX[3][3] =
{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
};
// clang-format on
/**
* @brief Does something.
*/
static void doFoo()
{
// ...
}
```
but in other conditions it does not happen. For example:
// clang-format off
static const int MATRIX[3][3] =
{
{ 1, 0, 0 },
{ 0, 1, 0 },
{ 0, 0, 1 }
};
// clang-format on
/**
* @brief Does something.
*/
static void doFoo();
Looks like this is mainly affected by `SeparateDefinitionBlocks`. However, looks like a bug and don't I see no logic in what is doing.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVU2P4ygQ_TX4UmoL4--DD0l7o21p97K7h71iXNh0E4gAJ5t_v8JJd5KRuo8zmpGQiaji5T0eVHHv1WQQO1JuSdknfAmzdR3X-MrN6KzQ3NlksOO52wTQyH0AZcChQBNAaG6mJ2ndngc4ovPKGiCsIflvJO8hKwlrCXt-zFMelPHogjITcPDBcTMhGDxpZRAGlNYhcHMGuRgRIuSIUhkVf6awsw7wP74_aCT5htCe0PdvRS9DELaN47LKdoTtHilYKS9BH3hQAoQ1q64Af27--evlX1Juc1L21wlI3l-x6isoAKm3kEVtdP0AqXvCnu-jayD7MnpJWaNX_J7kX_E2D3pjxiaOCy5hGyAFHZxCCb1FD97uMczKTOktJe661360arwsjHZnbXSPtd_IvRF8P2K4J6I8SOsEjvEI7S9syXc3Bj73BOBKJE3Tz1y6JzUs68u1YUYXT3dc35MHFWCMlIwNMPPDAb9-Yz-rdT_KtMe784e1bx60ekMIcyyEHvZcGX0GLiWKgCMMZyAV_RsP3PGA_Ufl22or3jypaAq_2xMe0UW5-gbIYVgm4Cb-vyGsDvACHhGMBW0nJaL7p_lSgEcbZSRjl49t3vIEu6xqaF23WVMkc9eIoR3KtilY20hW87wqa5FnjciqqkEpE9UxynJa0CrLaMWKtCgllbQtaxxaKpuSFBT3XOlU6-M-tW5KlPcLdlXWNjTRfEDt157DmMETrEHCWGxBrot7noZl8qSgWvngbyhBBY3dvY0k33z0kGsVioixlySL090cwsHHW7zegEmFeRlSYfeE7SLqdXo6OPuKIhC2W7l4wnYr1_8DAAD__4bb-W8">