[clang] [clang][analyzer] Detect use-after-move for 3-arg std::move (PR #196602)
Benedek Kaibas via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 21 05:26:57 PDT 2026
================
@@ -494,6 +507,77 @@ void MoveChecker::checkPostCall(const CallEvent &Call,
assert(!C.isDifferent() && "Should not have made transitions on this path!");
}
+bool MoveChecker::evalCall(const CallEvent &Call, CheckerContext &C) const {
+
+ const auto *CE = dyn_cast_if_present<CallExpr>(Call.getOriginExpr());
+ if (!CE)
+ return false;
+
+ ProgramStateRef State = C.getState();
+
+ if (!StdMoveCall.matches(Call))
+ return false;
+
+ const auto *POS = getIteratorPosition(State, Call.getArgSVal(0));
+ if (!POS)
+ return false;
+
+ const MemRegion *ContainerRegion = POS->getContainer();
+ if (!ContainerRegion)
+ return false;
+
+ const auto *TypedRegion =
+ dyn_cast_if_present<TypedValueRegion>(ContainerRegion);
+ if (!TypedRegion)
+ return false;
+
+ QualType ObjTy = TypedRegion->getValueType();
+
+ const auto *RD = ObjTy->getAsCXXRecordDecl();
+ if (!RD)
+ return false;
+
+ ObjectKind OK = classifyObject(State, ContainerRegion, RD);
+
+ // FIXME: Also apply getIteratorPosition from IteratorModeling to recover the
+ // destination region instead of doing AST pattern matching.
----------------
benedekaibas wrote:
I see your point. I have made changes [7374bbe](https://github.com/llvm/llvm-project/pull/196602/commits/7374bbe89cd58dcf849ad1a6662f8bbd1bd7df1c)
https://github.com/llvm/llvm-project/pull/196602
More information about the cfe-commits
mailing list