[all-commits] [llvm/llvm-project] d038fa: [clang-tidy] add option performance-move-const-arg...
Greg Miller via All-commits
all-commits at lists.llvm.org
Thu Feb 10 05:31:58 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d038faea4608f8f39602fb557666281c49de5722
https://github.com/llvm/llvm-project/commit/d038faea4608f8f39602fb557666281c49de5722
Author: Greg Miller <9447643+devjgm at users.noreply.github.com>
Date: 2022-02-10 (Thu, 10 Feb 2022)
Changed paths:
M clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
M clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
M clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst
A clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg-const-ref.cpp
Log Message:
-----------
[clang-tidy] add option performance-move-const-arg.CheckMoveToConstRef
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
```
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.
Reviewed By: ymandel
Differential Revision: https://reviews.llvm.org/D119370
More information about the All-commits
mailing list