[clang] [llvm] [analyzer] Implemented a base of detecing lifetimebound annotation (PR #200145)

Benedek Kaibas via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 10 05:10:26 PDT 2026


benedekaibas wrote:

> I think this potentially could be solved simpler! We do not need to store `(SymbolRef, Memregion*)` pairs. We could instead store `SymbolRef -> Set(MemRegion)` instead. And we could use an immutable set for the value of this mapping.

So I think I can implement something like this:

```cpp
REGISTER_SET_FACTORY_WITH_PROGRAMSTATE(LifetimeSourceSet, const MemRegion *)
REGISTER_MAP_WITH_PROGRAMSTATE(LifetimeBoundMap, SymbolRef, LifetimeSourceSet)
```
This looks like your suggestion for me. IIRC this is similar or the same as the mapping in the `InnerPointeChecker`. 

> Did you manage to figure out what test cases need the `MemRegion -> MemRegion` mapping?

Yes, I have done that yesterday. All the tests where the function body was available, so the checker could inline them, were failing without the `MemRegion` -> `MemRegion` mapping.

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


More information about the cfe-commits mailing list