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

    <tr>
        <th>Summary</th>
        <td>
            [clang-format] Formatting a file with unsorted includes adds an extra newline
        </td>
    </tr>

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

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

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

<pre>
    When formatting a file with unsorted includes, clang-format adds an extra newline after the includes.
I have to run clang-format a second time on the same file to remove this newline.

### Input
```cpp
#include <iostream>
#include <cstdint>

int main(int /*argc*/, char** /*argv*/) {
 uint64_t a = 1234;
  std::cout << "a: " << a << std::endl;
  return 0;
}
```

### Result
```cpp
#include <cstdint>
#include <iostream>


int main(int /*argc*/, char ** /*argv*/) {
  uint64_t a = 1234;
  std::cout << "a: " << a << std::endl;
  return 0;
}
```

### Expected result
This is obtained by running clang-format twice on the file.
```cpp
#include <cstdint>
#include <iostream>

int main(int /*argc*/, char ** /*argv*/) {
  uint64_t a = 1234;
  std::cout << "a: " << a << std::endl;
  return 0;
}
```

### .clang-format
```yml
---
SortIncludes: true
```

### Tools
```
$ clang-format --version
clang-format version 21.1.0
```

Using VSCode w/ the `clangd` extension (v0.2.0)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzcVUGP4yYU_jXPl6dYGOw4PvjgzWykuXa37bHC5jmmwhABTnb-fYWTzE5mq91W6qFaCcmGx_cB3_vgyRD00RK1UH2A6imTS5ycb4mPjpusd-ql_X0ii6Pzs4xR2yNKHLUhvOg44WKD85EUajuYRVEAvsfBSHvcXBEolQooLdKX6CVauhhtCeUYyWOc6BWYA-uecZJnwujQL_YdDQYanFUY9Uzo7IoNcqbrZhKEZpfAkw73ZRJnalxcGz7b0xLTyJZd23A6XSfctoEg9tqF6EnOID5-ExtCVNrGW4h12kacpbbAd-kX-AF4J_1xAN6tnT0Ok_Rrr_saPt_DDUL9AViHi7ZxW_6RDgriCQsuShBrBENUIDoQ3eCWmDYBYo_AuQSRKPl9SN5_XgFklbmzeIqLt8iufaif3srwXqdfKCzmh0I9ivE9Df-NVvhjsf5nan38cqIhXQJ_l-1zMqEO6PootSWF_UuytE3X58HW8aKHVzsnJ-f_peg_reL5WxHfTnyZDbBus9kA6z45H5_vz5LoMPqFvkf62TkT3k_g5WPCNpsz-aCdBdY9BG7DyIu8yNm36_waUvJ_-7R3ivAC_LCmPCU5sSjYsvREkl1JgO_OLOc5A95kqhWqEY3MqC3qqmb1bluU2dTuinpbVLJvmJSDGMemGqTsq76XO8VEv810yxmvWMOqQnAhynxXyGYcVDn2Y13UOwklo1lqkxtznnPnj5kOYaG2qOqC8czInkxYKwPnD4pznmqFbxNu0y_HACUzOsTwlSnqaNaq8gCsnvDwDyvJ31eObPGmnWI8pZSuHj0cdZyWPh_cDPyQ1r99Nifv_qQhAj-sxwrAD7eTnVv-VwAAAP__jSoHGA">