Author: flx
Date: Thu Jan 19 09:51:10 2017
New Revision: 292491

URL: http://llvm.org/viewvc/llvm-project?rev=292491&view=rev
Log:
[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

Modified:
    clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp
    
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp

Modified: clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp?rev=292491&r1=292490&r2=292491&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/DeclRefExprUtils.cpp Thu Jan 19 
09:51:10 2017
@@ -159,7 +159,8 @@ bool isCopyAssignmentArgument(const 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();

Modified: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp?rev=292491&r1=292490&r2=292491&view=diff
==============================================================================
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp 
Thu Jan 19 09:51:10 2017
@@ -247,6 +247,17 @@ void PositiveMoveOnCopyAssignment(Expens
   // 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