[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 Jan 12 08:50:05 PST 2023


Skylion007 added a comment.

I am trying this in the wild and getting some false positives where it tries to call std::move inside loop conditions and in the boolean condition for an if statement. Stuff like:

  if (auto* new_ptr = steal_ptr(std::move(old_ptr))) {
    ...
  }
  else {
    return old_ptr; // Now it's moved from and invalid
  }

Also this can be happen for similar boolean conditionals in while, for, do while loops.

Interestingly, the logic in bugprone-use-after-move flags this error so maybe we can reuse some of that logic to detect bad std::move.


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