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


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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to