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

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy bugprone-use-after-move gives false positive warnings in the move constructor for derived classes
        </td>
    </tr>

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

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

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

<pre>
    After https://github.com/llvm/llvm-project/commit/8c10256734cd47274671fcabe94f24f15ecd6209, bugprone-use-after-move checks constructor initialization list. But it gives a false positive warning in the move constructor of a derived class, when the constructor calls move constructor for a base class and moves some fields in the derived class.

An example is in https://cplusplus.com/forum/beginner/187808/. The code works. But clang-tidy gives below warning:

warning: 'sp' used after it was moved [bugprone-use-after-move]
   22 |     SpecialPerson(SpecialPerson&& sp) : Person{std::move(sp)}, surname{std::move(sp.surname)}{}
      | ^

To work around this, I can only use static_cast<Person&&>(sp) instead of std::move(sp).
Since this seems to be a common pattern of implementing move constructors for derived classes, it might worth fixing bugprone-use-after-move check in clang-tidy.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE2PozgQ_TXmUkoE5jMHDkn3RNrbSjP3lbEL8I6xkcsk0_vrV4ZEne5NrzSRAgmUq169evUEkR4sYsvKEytfE7GE0fn2TXTayqRz6q099gE9jCHMxPIj42fGz4MO49LtpZsYPxtzud92s3d_owyMn6WbJh1_NDJLeVnVeSFVUfO6qOqsl6LDQ9Hzos9KlKri6YHxF-iWYfbO4m4h3IlYeDe5C4IcUf4kkM5S8IsMzoO2Omhh9D8iaGfBaAp7OC0BdIBBX5BAQC8MIcyOdNAXhKvwVtsBtIUwImyZH1K6HgQo9PqCCqQRRBHTdcQt_jFUCmPovxl650FAJwi38yCsWqMIyE0IvUaj6A7gQ6k9S19ZetyuRwv4S0yzQdBr-Ef65WwWit_bBHrnl3jvcNDWomf8nDV1kzaMn_fwY8WuEK7O_6SNJGmEHXZBq7cbWR0ad70zFAs9oHl_CozXNDNew0KoYJ1QJPwqNjIUsPL0xRBZ-bqlAwDOgdUvED_fZ5RamD_Rk7OMN5_-V4xXEEseINa_Pa5PFFREmR_X1LxZQ1j9GidGi7diwqdR-_vLLbo-xesdFsAKi5XfHtv_4VbmQHi3WAVh1Ksu_gApLDhr3iIZQEEELf-SggLLXx7hs_zbHSBoSwGFilJ72sFNBd-1lbhWAkKcCIKDDkFA3CpnYRYhoLcxjY4qmdCGqOzPgqRVkR90hit4HWDSwxhiZ2GEXv-Kx_93_aIM32VzA5qoNleH_CASbLOqqXh5KIo0Gdu-zPIuLSqZlVxmWVceUi7VoeB5L_O8wES3POV5WqUNz3iRpnvsmr6Tncz6TKaq6ViR4iS02Udj2Ts_JJpowbbKecoTIzo0tNoW5xavsL5knEcX8-1qRt0yECvSaA30niXoYLB9WICvut4W47mH0Jcm8oTwZPGm_W0DXRsixs9rw_8GAAD__5Oo4Tg">