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

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy bugprone-use-after-move check does not catch misuse of std::forward<>()
        </td>
    </tr>

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

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

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

<pre>
    The clang-tidy bugprone-use-after-move check does not also evaluate perfect forwarding, which has similar risks.  Example:
```
#include <utility>

struct S {
  S();
  S(S&&);
};

void consume(S s);

template <typename T>
void forward(T&& t) {
 consume(std::forward<T>(t));
  consume(std::forward<T>(t));  // use-after-forward
}

void create() {
  S s;
 forward(std::move(s));
}
```
Live repro: https://godbolt.org/z/M3qWeW8Gh

Note that the clang-analyzer-cplusplus.Move check would have caught this case. (I don't know why there are two distinct use-after-move checks. Should one be turned down in favor of the other?)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE2T2ygQ_TXtS5ddMjiWdNBhMhNvbdVmLzNVOSNoSewgoYXGXufXbyFPRnGSS6owFh_d_d7jgYrR9hNRAx8-woenjUo8-NDMryqynfpN6821eRkItVNTv2Vrrtimfg5-om2KtFUdU9iO_kyoB9KvaDxFnDyjctEjnZVLiglnCh1pxs6HiwrGTj2IR7wMVg84qIjRjtapgMHG17hD_PSfGmdHIB-geILiAY7FW7sNhbSTdskQgnxMbJ3lK8hPb6tLHzkkzfiMUH68zSA-g6hA1CDvZp5BHJe2LkD5tH4v_dlbg9pPMY2UYzDe7V96pnF2mS7IR77ONKmR8OUd15LiTQEQ1cutLDKI-juQa43IJgsgH77FyMclmahyyD2P34tCBHECccL1DL_tfqf_E_dAiukm4J2mGFccK7t3GNkcefwD5LXE_dH-Zc-EgebgQT7gwDzHnGeB23vTesc7H3oQp68gTp_lv1_oS_XH8D3cvz0T8qAY-d26alLu-pXCVs8uxfzbfV5de_HJGRxUnlCpH3KkjahVpB2CqP5E4ycQJePr5C94Ga45dSBUgZAvHo3NF0Yz_upSxB0-D0sFPxG2hJzCRAaNv0xoJ-zU2Qf03QLX58QgTyDqjWmkqWWtNtTsy6LaF9WxkpuhKeqjMp0opZYHKWgv9l2hu7osy2Mplag3thGFOBRif9xXsirkjqhURzL77thSfSg7OBQ0Kut2zp3HrOfGxpioqUQh5MapllxcHgUh1qsPQuRHIjQ5aNumPsKhcDZyXNOwZUfN7z8XWrEecLQxRcpS_MLFNxNnXVJwzQ_OsDykdqf9COKUwbz9befg_yHNIE4LwQjitHD8PwAA__9J1oXR">