This revision was automatically updated to reflect the committed changes.
Closed by commit rC351500: [analyzer] MoveChecker: Add one more common 
resetting method, "append". (authored by dergachev, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56824/new/

https://reviews.llvm.org/D56824

Files:
  lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  test/Analysis/use-after-move.cpp


Index: lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -502,9 +502,9 @@
     std::string MethodName = MethodDec->getName().lower();
     // TODO: Some of these methods (eg., resize) are not always resetting
     // the state, so we should consider looking at the arguments.
-    if (MethodName == "reset" || MethodName == "clear" ||
-        MethodName == "destroy" || MethodName == "resize" ||
-        MethodName == "shrink")
+    if (MethodName == "assign" || MethodName == "clear" ||
+        MethodName == "destroy" || MethodName == "reset" ||
+        MethodName == "resize" || MethodName == "shrink")
       return true;
   }
   return false;
Index: test/Analysis/use-after-move.cpp
===================================================================
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -89,6 +89,7 @@
   void destroy();
   void clear();
   void resize(std::size_t);
+  void assign(const A &);
   bool empty() const;
   bool isEmpty() const;
   operator bool() const;
@@ -531,6 +532,13 @@
     a.foo();   // no-warning
     a.b.foo(); // no-warning
   }
+  {
+    A a;
+    A b = std::move(a);
+    a.assign(A()); // no-warning
+    a.foo();   // no-warning
+    a.b.foo(); // no-warning
+  }
 }
 
 // Moves or uses that occur as part of template arguments.


Index: lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -502,9 +502,9 @@
     std::string MethodName = MethodDec->getName().lower();
     // TODO: Some of these methods (eg., resize) are not always resetting
     // the state, so we should consider looking at the arguments.
-    if (MethodName == "reset" || MethodName == "clear" ||
-        MethodName == "destroy" || MethodName == "resize" ||
-        MethodName == "shrink")
+    if (MethodName == "assign" || MethodName == "clear" ||
+        MethodName == "destroy" || MethodName == "reset" ||
+        MethodName == "resize" || MethodName == "shrink")
       return true;
   }
   return false;
Index: test/Analysis/use-after-move.cpp
===================================================================
--- test/Analysis/use-after-move.cpp
+++ test/Analysis/use-after-move.cpp
@@ -89,6 +89,7 @@
   void destroy();
   void clear();
   void resize(std::size_t);
+  void assign(const A &);
   bool empty() const;
   bool isEmpty() const;
   operator bool() const;
@@ -531,6 +532,13 @@
     a.foo();   // no-warning
     a.b.foo(); // no-warning
   }
+  {
+    A a;
+    A b = std::move(a);
+    a.assign(A()); // no-warning
+    a.foo();   // no-warning
+    a.b.foo(); // no-warning
+  }
 }
 
 // Moves or uses that occur as part of template arguments.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to