[clang] [LifetimeSafety] Treat std::unique_ptr::release() as a move operation (PR #180230)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 6 11:51:53 PST 2026
================
@@ -546,6 +546,17 @@ void FactsGenerator::handleMovedArgsInCall(const FunctionDecl *FD,
void FactsGenerator::handleInvalidatingCall(const Expr *Call,
const FunctionDecl *FD,
ArrayRef<const Expr *> Args) {
+ // std::unique_ptr::release() transfers ownership.
+ // Treat it as a move to prevent false-positive warnings when the unique_ptr
+ // destructor runs after ownership has been transferred.
+ if (const auto *Method = dyn_cast<CXXMethodDecl>(FD);
----------------
Xazax-hun wrote:
Nit: maybe this could be moved a bit down, because we already have a check below if `FD` is a method and an instance call.
https://github.com/llvm/llvm-project/pull/180230
More information about the cfe-commits
mailing list