[clang] [analyzer] Detect dangling pointers passed to function calls (PR #211045)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 22 05:32:10 PDT 2026


================
@@ -73,7 +73,14 @@ std::vector<const MemRegion *> lifetime_modeling::getDanglingRegionsAfterReturn(
 
 bool lifetime_modeling::isDeallocated(ProgramStateRef State,
                                       const MemRegion *Region) {
-  return State->contains<DeallocatedSourceSet>(Region);
+  if (State->contains<DeallocatedSourceSet>(Region))
+    return true;
+
+  if (const MemRegion *Base = Region->getBaseRegion();
+      Base != Region && State->contains<DeallocatedSourceSet>(Base))
+    return true;
+
+  return false;
----------------
steakhal wrote:

```suggestion
  const MemRegion *Base = Region->getBaseRegion();
  return Base != Region && State->contains<DeallocatedSourceSet>(Base)
```

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


More information about the cfe-commits mailing list