[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

Aaron Gokaslan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 3 08:12:12 PDT 2022


Skylion007 added a comment.

I noticed one other bug from testing this out on some C++ codebases.

Specifically in pybind11 we have an object class which is a child of the handle object. The object class is non-trivially copyable, while the handle object is not. Therefore, when we do not want to increase / decrease the reference count of object, we often rely on object's implicit casting to a handle. While I suppose you could std::move() to cast an object for a handle, there isn't a good reason to do so. You get all the drawbacks of using std::move (ie. use after free bugs potentially) with none of the benefits.

Finally, this is a smaller issue but there seems to be a bug where the fix it can apply `std::move(std::move(obj));`. That is relatively low pri and not blocking by any means though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137205/new/

https://reviews.llvm.org/D137205



More information about the cfe-commits mailing list