[clang] [clang][analyzer] Detect use-after-move for 3-arg std::move (PR #196602)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 8 01:43:25 PDT 2026
================
@@ -1015,3 +1015,16 @@ struct OtherMoveSafeClasses {
// aggressive-note at -2 {{Moved-from object 'Task' is moved}}
}
};
+
+template<class Container>
+void safeOperatorAfterMove(Container lst) {
+ Container dest;
+ lst.push_back(typename Container::value_type {});
+ std::move(lst.begin(), lst.end(), std::back_inserter(dest)); // no-warning
+ lst.size();
+}
+
+template void safeOperatorAfterMove<std::list<int>>(std::list<int>);
+template void safeOperatorAfterMove<std::list<std::string>>(std::list<std::string>);
+template void safeOperatorAfterMove<std::vector<int>>(std::vector<int>);
+template void safeOperatorAfterMove<std::vector<std::string>>(std::vector<std::string>);
----------------
steakhal wrote:
```suggestion
template void safeOperatorAfterMove<std::vector<std::string>>(std::vector<std::string>);
```
https://github.com/llvm/llvm-project/pull/196602
More information about the cfe-commits
mailing list