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

    <tr>
        <th>Summary</th>
        <td>
            clang 18: Generated C++ spaceship operator triggers clang-tidy warning
        </td>
    </tr>

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

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

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

<pre>
    This program triggers a readability-implicit-bool-conversion clang-tidy warning:
```c++
#include <compare>
#include <list>

struct X
{
    auto operator<=>(const X&) const = default;
    bool m_b;
};

struct Y
{
    auto operator<=>(const Y&) const = default;
    std::list<X> m_xlist;
};

int main()
{
 return 0;
}
```

The warning emitted is the following:
```bash
main.cpp:6:46: warning: implicit conversion 'bool' -> 'int' [readability-implicit-bool-conversion]
    6 |     auto operator<=>(const X&) const = default;
      | ^
      | static_cast<int>( )
```

The clang-tidy command used:
```bash
clang-tidy --checks=-*,readability-implicit-bool-conversion main.cpp
```

It is somewhat unfortunate that a generated function triggers such a warning. Of course one can add NOLINT() statements to all affected operators but that unnecessarily clutters the code and makes it harder to read.

Is it possible to alter the generated code and avoid this warning?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVFFvozgQ_jXmZUQEJoTywEOaNKeVTrsvfdh9qow9gK_GRvbQXv_9ydAm6d721JNWQiQe7G9mvu_ziBB0bxEbVt6y8piImQbnm-nR1FXSOvXS3A86wORd78UI5HXfow8gwKNQotVG00uqx8loqSltnTOpdPYJfdDOgjTC9ilp9QLPwltte1bsWXZk2Z7tsvWRjN_GZ43yQltpZoXAioN04yQ8suLuV1-NDnT5tLwD-VkSfH-NVa-oAABiJgduQi_IeVYcWHGMh_mNdDbEI3zHeA3rihVHUNiJ2RArrkBifzA-tOcgq46X_9cl_Pj_Jfz4VAmBVOSw2K_tH76z4g7Gh7_X5YdlaUswCm0Zv2G8_rk4jzR7C9k7gPcyXYPdD_imJ-CoiVCBDkADQueMcc-_FLoVYVhDsZCNnCZW7Hes2G_j68og8OYnuLIS41Vkn_EK0tgy45W2FJesvP2MGVl5vLC4A1Yd4Lf5AhY4Vt79HAokSMsHKRatYsELNlw0-Ijfq6sj3TgKq2AOqP6L1qsjaSoHlI-BFceU8T3jh0_d17MwH9f2haLUwY34PAiC2XbO02wFIVAMCOjRRjZRQTdbSRH3PDfCLAcQb1pv4FsH0s0-IDiLIIUFoRR8_fbnl6_3q1UXCnFESwHIgTAGRNehjPhvsgVoZ1rTz9aixBCE1-YFpJmJYt5oTekUQuRxFI8YQBMMwiv0ETays3nX5rJhciHo1uCameLeAa8aPEOKJ6cVUJyVZx-fEtUUqi5qkWCTV_mu4tu8zpOhKcq6VIKXN2Wxlbza5ZjlXV4rzNpthipPdMMzvs1KvsvzbV3mm6wSrepU1SnZClns2DbDUWizMeZp3DjfJzqEGZu62GZ1YkSLJiwznfPFFYxzxg9vq8UjMVQeE99EiLSd-8C2WZwi4QJKmgw2yxnIb-LV_OPc-2Gd2xAmITEMejrLcZH73_M_mb1pBqIpRCfzE-OnXtMwtxvpRsZPMfXrTzp59xdKYvy0NBcYP639PTX8nwAAAP__9lsPEA">