[clang] [LifetimeSafety] Implement a basic use-after-free diagnostic (PR #149731)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 15 03:13:58 PDT 2025


================
@@ -723,17 +772,14 @@ join(llvm::ImmutableMap<K, V> A, llvm::ImmutableMap<K, V> B,
 // ========================================================================= //
 
 using OriginLoanMap = llvm::ImmutableMap<OriginID, LoanSet>;
+using ExpiredLoanMap = llvm::ImmutableMap<LoanID, const ExpireFact *>;
----------------
Xazax-hun wrote:

I am wondering if we could have multiple `ExpireFact`s for the same loan. E.g.:
```
{
  int a;
  int *p = &a;
  if (cond) return p;
  return q;
}
```

Here, because we have multiple returns, the loan might expire at multiple locations. How do we pick which one do we store in the state?

I wonder if we want some heuristics in the future. Also, if we pick randomly, could the analysis result be non-deterministic?

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


More information about the cfe-commits mailing list