[PATCH] D74692: [clang-tidy] Make bugprone-use-after-move ignore std::move for const values

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 19 19:56:33 PST 2020


Quuxplusone added a comment.

(I sent this to the mailing list, but I guess it doesn't show up here unless I do it through Phab. Quoting myself—)

I see your point about how users who care should always be passing this check alongside "performance-move-const-arg"; but IMHO it still makes sense for clang-tidy to warn unconditionally about code of the form

  x = std::move(y);
  use(y);

regardless of the incidental type of `y`. Sure, it's //technically// not wrong if `y` is const... or if `y` is a primitive type, such as `Widget*`... or if `y` is a well-defined library type, such as `std::shared_ptr<Widget>`... or if `y` is a library type that works in practice <https://stackoverflow.com/questions/60175782/is-stdlistint-listreturn-stdmovelistlist-guaranteed-to-leave/60186200#comment106478458_60186200>, such as `std::list<int>`... but regardless of its technical merits, the code is still //logically semantically// wrong, and I think that's what the clang-tidy check should be trying to diagnose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74692





More information about the cfe-commits mailing list