<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/88434>88434</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] `performance-move-const-arg` reports false positive when moving a type with a virtual destructor
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
sfc-gh-bhannel
</td>
</tr>
</table>
<pre>
When I pass an rvalue reference to the implicit move constructor of a type with a virtual destructor, I get a warning for `performance-move-const-arg`. The code actually performs a move, not a copy, and the warning is incorrect. Removing `std::move` would cause a copy where previously none occurred.
Minimal reproduction:
```
#include <utility>
struct S {
virtual ~S() = default;
};
int main() {
S s1;
S s2(std::move(s1));
return 0;
}
```
```
$ clang-tidy test.cpp
113 warnings generated.
/home/bhannel/Snowflake/trunk/ExecPlatform/test.cpp:9:8: error: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg,-warnings-as-errors]
S s2(std::move(s1));
^~~~~~~~~~ ~
Suppressed 113 warnings (112 in non-user code, 1 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
1 warning treated as error
$ clang-tidy --version
LLVM (http://llvm.org/):
LLVM version 16.0.0
Optimized build.
```
Reproduction in compiler explorer: https://godbolt.org/z/Excbed74j
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVU1v2zgQ_TX0ZSBBovwhHXxw4xgIkLaLprt7psmRxZYiBX7YdQ_57QtSUpwU2S3WEGSRnHkcvnnDYc7Jk0bcktUHstovWPCdsVvX8uzUZceOaY1qcTTiuv27Qw0PMDDngGmwZ6YCgsUWLWqO4A34DkH2g5JceujNGYEb7bwN3BsLpgUG_jogXKTvgMFZWh-YAoGzDaF38AAn9MDgwqyW-gStsUDWxYC2NbZnmmMWobMEnTF7Iusih69d3EwgMB4x1RUmBwcshRKhtYnA3AzXO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