<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJzNVl1v6jgQ_TXhZQTKB4XykIfbspXu-32vnGQCbo2dtZ2g_Ps9dgqFFl212rvSomDseHzOzJmxTWWasXxUQu_mv2QzktubXjV0FFaTqEzvye-ZWqOUOUq9o1o4dmRa6rXmmp0TdqTadJJdUvxI0m2SntpVOj111729yQupa9U3TEnxOHDtjU2Kv25NOm_B9j4Z21oJ5-gEv36YOl1fKVmfyQkfgN0734R3xY8Tz-P5zRmchiTfvC_DFA3Pl2sPZmCMo9mVJcjX2zd-Kwfh-cqBr5E_J8XDKZjtez-2Uns6CKnBDmY6R_tV7DMcIXkWKAFQIsQtpZiL3UfKYj_JH_DIiwgv6IiGBR86JWp-rkT9Gh3KwYQ2rHjnOSuCBJAAxDCFBfwnPHSQzoUS-qjuBa9l36Pw0ithrqvpvy2xPyb7p2WTEbk_mBgXDbAQqQjf27n4lD43pe3_k5bYQp--9p929-3dBM0-yP2NDfQlwJuFn10X_FTnl2OxGGImh-_p-22Ff-2lwxntcBz3EfwgXoylji1q6iB0zQTWnsngFKfOmhcESj8xxMzR2Fdu0F_QTw_mv3tpMRakjA8nO8xbqQKq0A2QdS8UjnjkzvIg-UjeUCsxJZQiU9e9tQxcR85gxUidgZpsHVUjQJ0XXtbTeqGFGh1c98Yo-BFumj2rru3V4kZ4VgcnjFYjvHgNBKxdjEkbPcd-GiRcGOe4fkZRKSY_drAKXk-9o_T7cIU5CXJuW4jgroieIJqpgjiT8ZUlSWxMBy4AiJZD2C99s4O0bbwUA21MQghXN0FSG63nxAPrk9mEf0LqXZC6hT6Ir3GLWVMWzabYiJno4awtWyTjKAae9VaVe--7eK_GUtrBw75a1OaAgVLD6Wf-lmAMY9axwZ_uiuX9ZrYvxTJNszRN75fL9XqZZWKzqTcVM69Ek3O7milRsXJlcoejJtfIboQIp8nddvbvPZBlnuZ5mhVplmd3WbEQ6zpvRLa6bzerqi3aZJky9qlaBJyFsbuZLSNk1e8cJpV0SNp5Ev8A5E4zR4fhoZdecdmwDxp_-E8ywovf7L5ZdLWMfv4D5duhnw>53489</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            detect unnecessary copy/missing std::move()
        </td>
    </tr>

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

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

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

<pre>
    Clang-Tidy should warn about the following cases of unnecessary copies:

```cpp
#include <vector>
#include <string>

class A
{
public:
    A(std::vector<std::string> v)
    : v_(std::move(v))
    {}
private:
    std::vector<std::string> v_;
};

int main() {
  std::vector<std::string> v;
  for(int i = 0; i < 10; ++i)
  {
    v.emplace_back("str");
  }
  A a{v}; // missing std::move()
  return 0;
}
```

```cpp
#include <vector>
#include <string>

int main() {
  std::vector<std::string> v;

  std::string s;
  for(int i = 0; i < 10; ++i)
  {
    s += " ";
  }
  v.emplace_back(s); // missing std::move()
  return 0;
}
```

```cpp
#include <vector>

struct A
{
    std::vector<int> v;
};

int main() {
    std::vector<int> v;
    v.emplace_back(1);
    A a;
    a.v = v; // missing std::move()
    return 0;
}
```

This was causing major performance issue on a project I once worked on. It required a lot of profiling and manual code review to find all occurrences so any pointers by a static code analysis tool would helpful.

This warning only makes sense on non-trivially-copyable types and types without side effects.

For objects with side effects it is not safe to judge if the copy was intended or not - even if the object is not used afterwards.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNVV1v4joQ_TXhZQSChI_ykIdt2Ur7vu-Vk0zArbFz_RGUf7_HTqHQVlettFe6KDh2PD5n5szYrkwzlA9K6P30t2wGcgcTVEMnYTWJygRP_sDUGqXMSeo91cKxI9NS0Jprdk7YgWrTSXZZ8SOb77L5uV3Px6fuutcveSF1rULDlBUPPdfe2Kz4-dmk8xZsb5OprZVwjs7wm_ux04VKyfpCTvgB7M75Jn4rf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