[PATCH] D138031: Add clang-tidy check for missing move constructors

Martin Bidlingmaier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 17 13:40:12 PST 2022


mbid added a comment.

Hi Nathan, thanks for looking into this. I did indeed not know about the existing check in cppcoreguidelines -- maybe I should've been more suspicious about assuming something so obvious supposedly doesn't exist yet :)

But perhaps the replacements could still be integrated into the existing check. Note that replacements in my patch are generated only if you have a defaulted copying version. So e.g. the defaulted move constructor is emitted only if the class has  a default copy constructor. This can still introduce bugs, but I think the probability for that is fairly low.

For context, I'm trying to run this on the chromium codebase, where copy constructors are required to be defined (even if = default) in the .cpp file for all non-trivial classes, which is why the implicit move constructors are often missing. I want to understand what the performance impact of that is.

> the replacements that this check generates would often not improve performance

Why would you expect there to be no improvement? If there's a default copy constructor and hence no (implicit) move constructor, than the more expensive copying version will be invoked when a move would be sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138031



More information about the cfe-commits mailing list