[clang] [analyzer] Fix false positive when a lifetimebound method is called during destruction (PR #210801)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 20 13:50:05 PDT 2026


================
@@ -43,6 +43,14 @@ static bool isDanglingStackSource(const MemRegion *Source,
           Source->getMemorySpaceAs<StackSpaceRegion>(State)) {
     const StackFrame *SF = StackSpace->getStackFrame();
     const StackFrame *CurrentSF = C.getStackFrame();
+
+    for (const StackFrame *DtorSF = CurrentSF; DtorSF;
+         DtorSF = DtorSF->getParent()) {
+      const auto *DDec = dyn_cast_or_null<CXXDestructorDecl>(DtorSF->getDecl());
+      if (DDec)
+        return false;
+    }
----------------
steakhal wrote:

I think this loop deserves a comment of why we ignore the dtors.

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


More information about the cfe-commits mailing list