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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] Check-request: modernize-use-operator-spaceship
        </td>
    </tr>

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

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

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

<pre>
    This check would suggest usage of `operator<=>` in 2 different ways:
1. Propose usage of `= default` if a class already implement `operator<=>` that can be defaulted.
```cpp
struct Point {
    int x;
    int y;

    auto operator<=>(const Point& other) const {
        return std::tie(x, y) <=> std::tie(other.x, other.y);
    }
};
```

Can be transformed to
```cpp
struct Point {
    int x;
    int y;

    bool operator<=>(const Point& other) const = default;
};
``` 
2. Find classes with `operator<`, `operator==` etc.. that can be replaced by a single `operator<=>`
```cpp
struct Point {
    int x;
    int y;

    bool operator<(const Point& other) const {
        return std::tie(x, y) < std::tie(other.x, other.y);
    }
    
    bool operator==(const Point& other) const {
        return std::tie(x, y) == std::tie(other.x, other.y);
    }
};
```

Can be transformed to
```cpp
struct Point {
 int x;
    int y;

    bool operator<=>(const Point& other) const = default;
};
``` 

This check can be improved iteratively.
I think the first part would be easier to implement: check that some `operator<=>` contains all its members and find some common-patterns like `std::tie` or _if-else_
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVcFu4zYQ_Rr6MpBAU7ZkH3TQxjXQ2x56X1DkSGJDiSpn5Kz79QVlp0l2m0uQojUImCQ4bx4fn2Y0kesnxFrsv4j9aaMXHkKsL-3FGQ5x0wZ7rX8bHIEZ0DzCU1i8BVr6HolhId0jhA5EKcOMUXOIongQxUkUv4hSgptAgXVdhxEnhid9JVE0QjbbHL7GMAfCNyCiOIHFTi-e1_AONBiviUD7iNpewY2zxzGBvZeTB81g9AQtPmOhzYVsEv46zDwL2RDHxTB8DS6BVV-EbAAA0uq7KF4vr7flfUcvHODnzOpgwkR3PKFKCDxgFOoIt_2XDOkXkZc4AbFNehQNOxTq8F2oB7immL9xfzyyoubrwds0HX-hK6pTYlqd7pSfr3yj_3BThaOeqAtxRAscPk-ZNgT_EWVePfoN7if6IGSjcji7yd78gARPjocfTVDKJMybzVMapQRkk-dvzBFx9tqghfYKGshNvcf3XPUvivTpxvmQZdbZPzJcBfxskgn0_2Lt_9jXQjavCuzdm26cY7igBccprbugv6Ya9ivw4KZH4AGhc5EYZh35XpZbBNTkMAKHl0IpiuaOvZqfwviuyxNx1m5K5daDY4IRxxYjgZ4sdOnrW8NNGMcwZbNmxjgRePe4Yr550FJCiPDNdRl6wm8bWxf2WBz1ButtVRwPx-OhrDZDjcdur6w2R4Om7HbbThZG6rYrC4V7Wx42rlZS7aXaHrZVsZVVbrpS7sxur8zWKrnbiZ3EUTufe38Z8xD7jSNasN6qqqzUxusWPa0dTinj9dRn7OxVKJU6XqxTVNYuPYmd9I6YXnDYsV9746uw_QkekpxZxD8WpFXfMViMk_sTs4Uwe5Y2o1kbpMHNmyX6emCe1_anzkKde8fD0uYmjEKdU8L7XzbH8DsaFuq83oKEOt8vcqnVXwEAAP__KFhP6w">