[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:23 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);
----------------
steakhal wrote:

It's always present - you just checked it at the prev if.

```suggestion
      const auto *TypedRegion = dyn_cast<TypedValueRegion>(ContainerRegion);
```

https://github.com/llvm/llvm-project/pull/196602


More information about the cfe-commits mailing list