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

    <tr>
        <th>Summary</th>
        <td>
            Clang-tidy 'use-after-move' assumes left-to-right function argument evaluation order
        </td>
    </tr>

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

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

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

<pre>
    Consider the following example:
```cpp
#include <memory>

void foo(std::unique_ptr<int>, int*) {}
void bar(int*, std::unique_ptr<int>) {}

int main() {
  // clang-tidy warns about bug-prone use-after-move:
  auto s = std::make_unique<int>(0);
  foo(std::move(s), s.get());

  // No warning:
  auto t = std::make_unique<int>(0);
  bar(t.get(), std::move(t));
}
```
Since argument evaluation order in function calls is not specified by the C++ standard, both in the call to `foo` and `bar` it is not specified whether the call to `get` happens before or after the move constructor for the other argument is called. However, clang-tidy only warns about the call to `foo`, where the move is in the first argument and the call to `get` is in the second argument.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVMuy2yAM_Rq80SST4PiRhRf3Jr3TVTf9gDvYlm1aDC7gpPn7CvJsettFM4xjkHR0JB1cm_ZU7Yx2skULfkDojFLmKHUP-FOMk0KWvrDVnq1eWL46r2aaLic8lbpRc4vA0t2Io7Enln66GOPzYGRLmIbx0vk2YKUvs5Y_ZnyfvKUoqX0I4TsIb5wwt8CKV1bsHwBqYQng6rCDf0P9DnB-kg1GITXBXB3iOQDjb7SgUUL3Cy_bExyF1Q5EbWYP9dwvJms0wuxwITqPdjGaw70rAGL2Bhx1YH_nNYrv-H4m90CsXFFult5SP_Ul4tI-OIUilz36M9_HsCfeX0zkSwN7puT_h9K50_4x9UO7Lwz9M6Vbr68SOW-_kjoQhO3nEan_eBBqFl4aDcYGvUkN3aybeNIIpRxIB9p4cBM2spNIkz9FVe4Yf6VFTIRuhW0Dq9r4IUAEe4gGqplSh6bmKyC_sAv10E76P6GPA1KofY4PlVPEIKYJSQY1dsYiEYY4_Ogd2gAN3Rpv58aTiVyiwUTAW8GUMgBju4TP5ogHtIH3g9KMVr_L7cNaQhCRJRa35IR8qbyT1vl7ylD2xwXdQxwS9_YWs0ywWudZueUrXpZJW6XtNt2KxEuvsNrd2TJePF0CXoBwjlAcKOz8wpuFlf3g72P96_CT2apq8H5yQVpRy730w1wvGzPSRqnD9S9cwG_YkOreJGVDuiBvWV5symSoNgUv8k0u-CZPayzWdZqnZVGm3aYpszTjiRI1KlexjPTDNR4hQtA7y_aJrKhmviKMNf14scSu2wqR1VlRrusiL9lmhfTZUMvAY2lsn9gqUqLvgiOjks67u5GaIXuNGNMRPt3DwdhqrGWbxLxV5P0LWbiz2w">