<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/154796>154796</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-format] Incorrectly merged empty records with default config
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-format
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          itzexpoexpo
      </td>
    </tr>
</table>

<pre>
    During PR #154580 we noticed that empty records (``struct``,``union``,``class``) get incorrectly merged by clang-format running on default config:
```c++
struct foo {};
struct bar {
  int i;
};
```
This happens even if with `BreakBeforeBraces: Custom` and `BraceWrapping.SplitEmptyRecord: true`.
Expected output in both cases is:
```c++
struct foo {
};
struct bar {
  int i;
};
```

Behavior is correct if `BraceWrapping.AfterStruct: true`:
```c++
struct foo
{
};
struct bar
{
  int i;
};
```

Occurs at least since version 20.1.0 and is likely an issue in `LineJoiner::tryFitMultipleLinesInOne` or it's callees.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVF2vozYQ_TXmZXSRMcGEBx7IZiNt1Wqr3Up9NmYAdx0b2ePcm_76CpLej15VuloJhDXjGZ9zPAcVo5kcYsuqA6uOmUo0-9Aa-hufFr--We-Ha3tMwbgJfv8GTJRFtav2HB4RnCejcQCaFQGeF7pCQO3DEIGJPZOcSR4pJE23NROfbovkjHf_iWmrYvw31sCEBMZpHwJqslc4Y5hwgP4K2io3PYw-nBVBSM6t0LyDAUeVLIH2bjQTKzvGu3s_yTUTh_Xh3Q0QjN4Dqw-sPrLyVbhXYQvzDsA4AnPLPm97bsh498dsIsxqWdBFwAs6MCM8GpqBSX4IqH4ccPQBD0FpjKzs4FOK5M9MclBuuO1SGv8MalmMm_LvizX0edXx2ybjWkIhIZM8Z7z7_LSgJhzAJ1rSKg_0nmbQKmIEEz9K-RWdn2DNeHfAWV2MD2Ai3G9opf6OTzcShu-3AXih8gGY29n_A_Q59yGoX7VOIYIisKgiQTROI1wwROMdCJ4X-e0yTARrfqC9gnJgYky46ssk_9U4_MUbh2EFXnYUridDvyVLZrG4ZuMX99WtzGCVhJioI2hlLWLMs6Eth6ZsVIZtUVdV3VSFlNncVlw1xYiN5JI3Ix_HEuVeYaH6uh6aZp-ZVnBR8b0oClmJncxlqYumL5tK4G6neM12HM_K2Nzayzn3Yco22G1R7epGZlb1aOPmbCFee4YJsXo9tGvdQ5-myHbcmkjxpRMZsttf4U1hdYQv7y351vjb_L-1YpaCbWeiZZtQcWLiNBmaU59rf2bitJ56_zwswf-Fmpg4bWQiE6c7n0sr_gkAAP__gp1x_w">