[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


================
@@ -255,6 +255,26 @@ template <typename T> static bool isRecordWithAttr(QualType Type) {
 bool isGslPointerType(QualType QT) { return isRecordWithAttr<PointerAttr>(QT); }
 bool isGslOwnerType(QualType QT) { return isRecordWithAttr<OwnerAttr>(QT); }
 
+static bool isStdUniquePtr(const CXXRecordDecl *RD) {
+  if (!RD || !RD->isInStdNamespace())
+    return false;
+
+  StringRef Name;
+  if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
+    Name = CTSD->getSpecializedTemplate()->getName();
+  else if (RD->getIdentifier())
+    Name = RD->getName();
+  else
+    return false;
+
+  return Name == "unique_ptr";
+}
+
+bool isUniquePtrRelease(const CXXMethodDecl *MD) {
+  return MD && MD->getIdentifier() && MD->getName() == "release" &&
----------------
Xazax-hun wrote:

We have null checks both here and at the call site, should this take a reference instead?

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


More information about the cfe-commits mailing list