forked from OSchip/llvm-project
[clang-tidy] Do not trigger move fix for non-copy assignment operators in performance-unnecessary-value-param check
Reviewers: alexfh, sbenza, malcolm.parsons Subscribers: JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D28899 llvm-svn: 292491
This commit is contained in:
parent
c3cb054e0c
commit
08df246407
|
@ -159,7 +159,8 @@ bool isCopyAssignmentArgument(const DeclRefExpr &DeclRef, const Decl &Decl,
|
|||
parmVarDecl(hasType(matchers::isReferenceToConst())));
|
||||
auto Matches = match(
|
||||
decl(hasDescendant(
|
||||
cxxOperatorCallExpr(UsedAsConstRefArg, hasOverloadedOperatorName("="))
|
||||
cxxOperatorCallExpr(UsedAsConstRefArg, hasOverloadedOperatorName("="),
|
||||
callee(cxxMethodDecl(isCopyAssignmentOperator())))
|
||||
.bind("operatorCallExpr"))),
|
||||
Decl, Context);
|
||||
return !Matches.empty();
|
||||
|
|
|
@ -247,6 +247,17 @@ void PositiveMoveOnCopyAssignment(ExpensiveMovableType E) {
|
|||
// CHECK-FIXES: F = std::move(E);
|
||||
}
|
||||
|
||||
struct NotCopyAssigned {
|
||||
NotCopyAssigned &operator=(const ExpensiveMovableType &);
|
||||
};
|
||||
|
||||
void PositiveNoMoveForNonCopyAssigmentOperator(ExpensiveMovableType E) {
|
||||
// CHECK-MESSAGES: [[@LINE-1]]:69: warning: the parameter 'E' is copied
|
||||
// CHECK-FIXES: void PositiveNoMoveForNonCopyAssigmentOperator(const ExpensiveMovableType& E) {
|
||||
NotCopyAssigned N;
|
||||
N = E;
|
||||
}
|
||||
|
||||
// The argument could be moved but is not since copy statement is inside a loop.
|
||||
void PositiveNoMoveInsideLoop(ExpensiveMovableType E) {
|
||||
// CHECK-MESSAGES: [[@LINE-1]]:52: warning: the parameter 'E' is copied
|
||||
|
|
Loading…
Reference in New Issue