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

    <tr>
        <th>Summary</th>
        <td>
            clang-format doesn't handle the spaceship "<=>" symbol correctly
        </td>
    </tr>

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

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

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

<pre>
    I was referred here to post a potential bug in the clang-format application.

I am running Ubuntu 24.04. The version of clang-format is:

```
$ clang-format --version
Ubuntu clang-format version 18.1.3 (1ubuntu1)
```

I use this file:
```
#include <stdio.h>
#include <compare>

int main() {
  int x = 5;
  int y = 6;

  if ((x <=> y) != 0) {
    printf("x is not equal too y\n");
  }
}
```

I can compile and run it.

```
$ g++ -std=c++23 spaceship_test.cpp
$ ./a.out
x is not equal too y
```

I then run clang-format and try to compile:
```
$ clang-format -i spaceship_test.cpp
$ g++ -std=c++23 spaceship_test.cpp
spaceship_test.cpp: In function β€˜int main()’:
spaceship_test.cpp:11:13: error: expected primary-expression before β€˜>’ token
   11 |   if ((x <= > y) != 0) {
      |             ^
```

Indeed in the file the <=> has been changed to "<= >" Notice the space symbol after the "=".

```
#include <stdio.h>
#include <compare>

int main() {
  int x = 5;
  int y = 6;

  if ((x <= > y) != 0) {
    printf("x is not equal too y\n");
  }
}
```

Here is the clang-format file I am using [clang-format.txt](https://github.com/user-attachments/files/18414723/clang-format.txt). I had to add a .txt in order for the tool to accept the .clang-format file


I assume this is some sort of bug in clang-format.

Thanks
Chris
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVUFzszYQ_TXry44ZkCDAgYMTx9Ncevp67ghYjPqBRKUljf99R0DqOHH7TWd6aCYDeKV9etJ7u1Le67MhqiB7hOy4UzP31lVN77T_brnI411t20v1gn8oj446co5a7MkRssXJekaFk2UyrNWA9XxGbZ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