Author: dergachev Date: Thu Jan 17 16:16:25 2019 New Revision: 351500 URL: http://llvm.org/viewvc/llvm-project?rev=351500&view=rev Log: [analyzer] MoveChecker: Add one more common resetting method, "append".
This is especially crucial for reports related to use-after-move of standard library objects. rdar://problem/47338505 Differential Revision: https://reviews.llvm.org/D56824 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp cfe/trunk/test/Analysis/use-after-move.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp?rev=351500&r1=351499&r2=351500&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp Thu Jan 17 16:16:25 2019 @@ -502,9 +502,9 @@ bool MoveChecker::isStateResetMethod(con 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; Modified: cfe/trunk/test/Analysis/use-after-move.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/use-after-move.cpp?rev=351500&r1=351499&r2=351500&view=diff ============================================================================== --- cfe/trunk/test/Analysis/use-after-move.cpp (original) +++ cfe/trunk/test/Analysis/use-after-move.cpp Thu Jan 17 16:16:25 2019 @@ -89,6 +89,7 @@ public: 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 @@ void moveStateResetFunctionsTest() { 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