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

    <tr>
        <th>Summary</th>
        <td>
            clang-format does not place `file.cuh` include at the top in `file.cu`
        </td>
    </tr>

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

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

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

<pre>
    Normally, whenever clang-format formats a file, it recognises the header for the current file and places it at the top. This does not work for CUDA headers and sources. Formatting works, but the header is not placed at the top.

Here are the files to reproduce, and also how they look after formatting.

#### `util.cuh`
```cuh
#ifndef UTIL_CUH
#define UTIL_CUH

#include <stdbool.h>

#define CHECK(e) \
    { _check_cuda_error((e), __FILE__, __LINE__); }

void _check_cuda_error(const cudaError_t code, const char *const file,
 const int line);

#endif  // UTIL_CUH
```

#### `util.cu`
```cu
#include <stdio.h>

#include "util.cuh"

void _check_cuda_error(const cudaError_t code, const char *const file,
                       const int line) {
    if (code != cudaSuccess) {
        (void)fprintf(stderr, "error: [%s:%d] %s\n", file, line,
                      cudaGetErrorString(code));
 exit(code);
    }
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VEFv6zYM_jXyhWhgS7VjH3xInWYtVrzLe93VUCQ61qpIgSS3678fJDtpXl837LLCqC3qI_nxI0PuvToYxJaUd6TcZnwKo3Xtc3jhzo9_oDvybG_le_vNuiPX-p3QDt5GNPiKDoTm5nAzxKsA88sDh0FpjDgVwKGwB6M8eggjwohcoovQdBSTc2hCcgBuJJw0F-ijIw8JEexpBT9G5UFa9GBsgDfrXlKE7nm7WSL65O3t5AT6FewSlaDMIaF9JLOfwjUFNQdLCeV1NpJvSb6Z_z-gQ-AO02Uk6SFYcHhyVk4i1Rjzcu0tjPYtwt5BW_sCfAhznQuPn8ISyi4PkCqfgtIrMY2kyhdAlc9PNJ5d1GAkDvD84_Gp754fLnaJgzL42X7xMkJPEoGwzge5t1avRsLuP6GWGN3Dffc7oTUS2gApu_keAICs76AXI4qXXkyS9-icdYTWCzgq0fe7x6f7vp-_nx6_pe-GsDsg6-11wler5JfRhDU-QDTdR0sfQFiZZF5uRu6A0M18WsZsITnblAmglcE58acq0Ug1ABC6I3T3WbCz5P-hUV_16R8EV_YruS8YSi-9p_R_l-jrv1-Ei83-8FADpLSJbkHYNiX_PgmB3v-CTrNC60if0GY4OWXCQGjtg0TnIk1C6VwL20BcOrT0hG0ILSUpt5COZWeiHLS7bJKZ2b_WEVn9hiGp8j04ZQ4L7TSeH9MA-JcKV1fs7nrKz3N6-Th3OJMtkw1reIZtsabrdcGavMnGFsW6FrxsWFVX5boRrNkXa0nrW1YXlayrTLU0p7d5w_KiYsVtvRJ1KapqX-Q1ljllA7nN8ciVXmn9elxZd8iU9xO2RZGXjGaa71H7tKApvd64UaNym7k2-t3sp4Mnt7lWPviPSEEFje1Pe_qySNPui2MdVV72D5xH82MjgjJXoCjF5HQ7hnCaGxd_TAcVxmm_EvZI6C4mX143J2f_RBEI3aWaPKG7pazXlv4dAAD__yh-7Q8">