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

    <tr>
        <th>Summary</th>
        <td>
            detect unused static functions in local classes/structs
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    ```cpp
class C
{
    static void s_f() {}
};

struct S
{
    static void s_f() {}
};

namespace {
    void anon_f() {}
}

namespace ns {
    static void ns_f() {}
}

static void f() {}
```

```
<source>:12:10: warning: unused function 'anon_f' [-Wunused-function]
   12 |     void anon_f() {}
      | ^~~~~~
<source>:16:17: warning: unused function 'ns_f' [-Wunused-function]
   16 |     static void ns_f() {}
      | ^~~~
<source>:19:13: warning: unused function 'f' [-Wunused-function]
   19 | static void f() {}
      | ^
```

https://godbolt.org/z/9s9YG5G7j

One could argue that an unused regular method in a local class/struct (not in the example above) is similar to this and could also be diagnosed.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVE2PozgQ_TXmUkoE5QDhwCHd6fRxD3tY7WlU4Aq45dgRNumZOcxvH5mE_lJ60oeJosLAq1evXmGT97qzzLXI70S-TWgMvRvqvR74mU6cNE79qEWRnv_t8SjSrUg3rSHv4f58I8q78wIAwAcKuoWT0wr8t73AtcAKIqTczvCtkJeMc_RhGNsA__4lOksH9kdqGd5RTRxknf2U5iqH9fCpIvu5pHftvWZchc_2vk36-FDeezcOLQv5IOQmwxhSITfwTIPVtovL0Y6eFexH2wbtLAgs535LEPnd4r8zYjEjRL59aSxDEOU93HZqgkxYkT_8ir_rEosYytsSzyZ-QWDxIvALM_io8rrGKgZ5W-PXBFZTvVvjfqfsD19AH8LRC7kRuBO465xqnAlLN3QCdz8F7ipf_f-YP5ZPb5P-sQytG40CGrqRIfQUgOzc08DdaGiAA4feKdAWCIxrycC0owXuLntR4Nq6EAGhZ-DvdDgaBmrciWM_2oPXBx2pgoPQaw9k1VzZeAcNg9LUWedZLRNVS1XJihKus6Kq1jIrqnXS13K_x5ZWnBHmvFfZqmiKCpEIMV8ppkTXmKLMsgxR4jpbLxUVjFISc1GgSguxSvlA2iyNOR2iO4n2fuS6xLRME0MNGz8dboiWn2F6KRDjWTfUMWfRjJ0Xq9RoH_wrS9DBcK04cBtm9y6TnWfvoz1v3ONX_3wyDqb-MEEd-rFZtu4gcBfrXC6L4-CeuA0Cd5O6yDKp_x0AAP__PD-fiA">