[PATCH] D28899: [clang-tidy] Do not trigger move fix for non-copy assignment operators in performance-unnecessary-value-param check
Felix Berger via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 19 08:02:16 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292491: [clang-tidy] Do not trigger move fix for non-copy assignment operators in… (authored by flx).
Changed prior to commit:
https://reviews.llvm.org/D28899?vs=84960&id=84967#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28899
Files:
clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
Index: clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp
+++ clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -159,7 +159,8 @@
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();
Index: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -247,6 +247,17 @@
// 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28899.84967.patch
Type: text/x-patch
Size: 1722 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170119/89e725df/attachment.bin>
More information about the cfe-commits
mailing list