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

    <tr>
        <th>Summary</th>
        <td>
            `-Wunused-function` false positive for `friend operator<=>` in unnamed namespace
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            false-positive
      </td>
    </tr>

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

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

<pre>
    ```cpp
#include <compare>

namespace {

struct S {
    friend auto operator<=>(const S&, const S&) = default;
};

[[maybe_unused]] bool awoo(S a, S b) { return a == b; }

}
```
When compiling with `-std=c++20 -Wunused-function`, we get this output:
```cpp
<source>:6:17: warning: unused function 'operator<=>' [-Wunused-function]
    6 |     friend auto operator<=>(const S&, const S&) = default;
      |                 ^~~~~~~~
1 warning generated.
```
This is obviously a false positive. If `<=>` was unused, then `a == b` wouldn't compile.

This only occurs in a very niche circumstance. Any one of the following doesn't get a warning:
- using `a <=> b`
- not using an unnamed namespace
- defaulting `operator==` and using `a != b`, which similarly relies on expression rewriting
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVE2PozgT_jWVSykR2AGSAwcSOtJ77lea48qYInjl2Mgfyeayv31lINPZ6TkuihQD5qnno8rCe3U1RDUUJyjajYhhtK7-UJ7MQ9xp09n-WUOZLT85TZA1wLgyUseeEPhZ2tskHAH_SK-yxogb-UlIQqhOyyMfXJQBP9cniIiDU2R6FDFYtBM5EawDfgbeJiB2kNb4gJ_ASmBnfL87IvAWexpE1AH4XKJq10XWzEJON_Hs6I9ooqceihaKFjtrNYqHtcAOnygS7Cd2M151QkchOoMCZwYtdsBPmHAX0GXxsgGy5sdIBpN0pZW54kOFEaHMtj70wFsJ7ATsxDLc_lhIbIdoZFDWpM_ZGR-EVwoYRuXRxjDFALx5r7Fazc_eRidne3lTAm_yCniDD-GMMte0XArgqwACq37jaIVQnL6zKdo1kBKhOuN_Hs2M-BP6_YLi4-_lgqzJX4LwSiaVpH73i-P_T1Ylt7q7stHrJwochPaEk_UqqDvt8H9DCuGLbJnhQ_jVocQ2pNigzN5yTnts1L0BVoU1Utotuc81rdFPtFJG51GlFrmTe6JRciSUysl480EYSTtszBOtIbRDKoSD1do-kqjekl_wU-jiLT3Imi1GnzattFbuM7P5rbFh3SEMRpPmq8efUzZvWS1fUb5CSxKTQGH6fxVh-Uv73IujkiN6dVNaOP1ER1pR0o301-TI-9RVjh5OpQqbvub9kR_Fhuq84gfO-XFfbcZ64EN3KPOq2O-7Q16xYqjKfM_KQbJOSj5sVM0yVmQ5z_M9Z6zaDd1xoJIf-5xTJfYE-4xuQumd1vfbzrrrRnkfqc5ZwTjfaNGR9vNRxdgc_fYVPTCWji9Xpy-3Xbx62Gda-eC_sIIKmtJZ9ruZ_KWVcLAuebXOwvcxKLPUC9_S2ESn6zGEyads2QXY5arCGLudtDdgl0Rm_dtOzv5JMgC7zCo9sMsq9F6zfwIAAP__YM-1nQ">