[clang] [clang][analyzer] Detect use-after-move for 3-arg std::move (PR #196602)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 8 04:06:03 PDT 2026
================
@@ -642,6 +726,41 @@ void MoveChecker::checkPreCall(const CallEvent &Call, CheckerContext &C) const {
// class in which the encountered method defined.
ThisRegion = ThisRegion->getMostDerivedObjectRegion();
+ // Store class declaration as well, for bug reporting purposes.
+ const CXXRecordDecl *RD = MethodDecl->getParent();
+
+ if (MethodDecl->getOverloadedOperator() == OO_Star ||
+ MethodDecl->getOverloadedOperator() == OO_Arrow) {
+ SVal Val = IC->getCXXThisVal();
+
+ if (const auto *POS = getIteratorPosition(State, Val)) {
+ const MemRegion *ContainerRegion = POS->getContainer();
+ if (!ContainerRegion)
+ return;
+
+ const auto *TypedRegion =
+ dyn_cast_if_present<TypedValueRegion>(ContainerRegion);
----------------
Xazax-hun wrote:
Or alternatively, the null check can be deleted above.
https://github.com/llvm/llvm-project/pull/196602
More information about the cfe-commits
mailing list