<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61257>61257</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-tidy: performance-move-const-arg strange failure
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JVApen
</td>
</tr>
</table>
<pre>
Bug linked to https://discourse.llvm.org/t/some-instances-of-performance-move-const-arg-suggest-a-fix-others-do-not/69055/2?u=jvapen
In case of
````
void f(int &&);
void g()
{
int i = 0;
f(std::move(i));
}
````
Clang-tidy gives a warning that this move has no effect, though removing it makes the code invalid. This was identified in https://github.com/llvm/llvm-project/commit/a7f8aea71485c00db2ffb6288ae58475869048b1
As such, I believe this report is not that relevant and with std::move being elided due to recent changes, even on O0, I don't understand the performance impact it can have.
Assuming we want to keep this case, I would expect this to be reported on the definition of the function. That would be the place where the unneeded && can be detected and both definition and declaration can be updated.
Though, I don't believe this has nothing to do with performance, one could argue that it should not even be reported.
Possible fixes:
- add extra diagnostic on function definition
- optionally: remove current diagnostic
- remove the diagnostic
- make it configurable that next to CheckTriviallyCopyableMove, it does not report if function requires the move
- move the trivially copyable detection to a separate check
If it is decided what option to take, this could be a good beginners bug.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVUFv6zYM_jXKhXDgyLHjHnJIWwR4A4btUOwuS7TNV1vyJNlp__1AOW2SDe8wwEgsySS_j_xIqRCos4hHUT6L8nWj5tg7f_ztr9OEdtM483l8njsYyL6jgeigj3EKojgJeRbybChoN_uA22FYxq3znZDnKOQ5uBEzsiEqqzFkrs0m9K3zI6-z0S2YaWdDzJTvsjB3HfJ71tJH5mKPPmTGZdaxq-opL0shz1IU51kUrz8XNaEV-avIT-vvDwtaBQTXXner_PakncWRgVbImmwEIav0PIni-e64E7LmzdXF4XoEAMBGBKJ4hfzbJHkL0XAqihM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