[PATCH] D119370: feat: add option performance-move-const-arg.CheckMoveToConstRef

Greg Miller via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 9 13:05:53 PST 2022


devjgm created this revision.
Herald added a subscriber: carlosgalvezp.
devjgm requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

This option allows callers to disable the warning from
https://clang.llvm.org/extra/clang-tidy/checks/performance-move-const-arg.html
that would warn on the following

  cc
  void f(const string &s);
  string s;
  f(std::move(s));  // ALLOWED if
  performance-move-const-arg.CheckMoveToConstRef=false

The reason people might want to disable this check, is because it allows
callers to use `std::move()` or not based on local reasoning about the
argument, and without having to care about how the function `f` accepts
the argument. Indeed, `f` might accept the argument by const-ref today,
but change to by-value tomorrow, and if the caller had moved the
argument that they were finished with, the code would work as
efficiently as possible regardless of how `f` accepted the parameter.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119370

Files:
  clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
  clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg-const-ref.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119370.407261.patch
Type: text/x-patch
Size: 4279 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220209/6e29f917/attachment-0001.bin>


More information about the cfe-commits mailing list