diff options
| -rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp | 6 | ||||
| -rw-r--r-- | clang/test/Analysis/use-after-move.cpp | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp index 6efa2dfbe5b..95b5ac6d1dd 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp @@ -502,9 +502,9 @@ bool MoveChecker::isStateResetMethod(const CXXMethodDecl *MethodDec) const { 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; diff --git a/clang/test/Analysis/use-after-move.cpp b/clang/test/Analysis/use-after-move.cpp index 280724512f8..435976c5a7c 100644 --- a/clang/test/Analysis/use-after-move.cpp +++ b/clang/test/Analysis/use-after-move.cpp @@ -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. |

