[PATCH] D21223: [clang-tidy] misc-move-const-arg: Detect if result of std::move() is being passed as a const ref argument

Martin Böhme via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 10 02:56:34 PDT 2016


mboehme created this revision.
mboehme added reviewers: alexfh, hokein.
mboehme added a subscriber: cfe-commits.

Conceptually, this is very close to the existing functionality of misc-move-const-arg, which is why I'm adding it here and not creating a new check. For example, for a type A that is both movable and copyable, this

  const A a1;
  A a2(std::move(a1));

is not only a case where a const argument is being passed to std::move(), but the result of std::move() is also being passed as a const reference (due to overload resolution).

The new check typically triggers (exclusively) in cases where people think they're dealing with a movable type, but in fact the type is not movable.

http://reviews.llvm.org/D21223

Files:
  clang-tidy/misc/MoveConstantArgumentCheck.cpp
  docs/clang-tidy/checks/misc-move-const-arg.rst
  test/clang-tidy/misc-move-const-arg.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21223.60327.patch
Type: text/x-patch
Size: 9431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160610/183970ff/attachment.bin>


More information about the cfe-commits mailing list