[clang] [analyzer] Only report the first dereference of the same variable in DanglingPtrDeref (PR #215409)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 11 02:36:21 PDT 2026
================
@@ -86,6 +87,13 @@ bool lifetime_modeling::isDeallocated(ProgramStateRef State,
return State->contains<DeallocatedSourceSet>(Region->getBaseRegion());
}
+ProgramStateRef lifetime_modeling::markAsReported(ProgramStateRef State,
+ const MemRegion *Region) {
+ if (State->contains<ReportedDeadRegions>(Region->getBaseRegion()))
+ return nullptr;
+ return State->add<ReportedDeadRegions>(Region->getBaseRegion());
----------------
steakhal wrote:
This is the usual double lookup problem. This is my pet peeve.
`add` is idempotent (identity) if the thing you wanna put into was already there. You could add unconditionally and check if the resulting state is different. If so, the addition succeeded. If not, then return `nullptr`.
https://github.com/llvm/llvm-project/pull/215409
More information about the cfe-commits
mailing list