[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 Jul 25 10:27:28 PDT 2025
================
@@ -492,7 +522,8 @@ class FactGenerator : public ConstStmtVisitor<FactGenerator> {
// Check if the loan is for a stack variable and if that variable
// is the one being destructed.
if (LoanPath.D == DestructedVD)
- CurrentBlockFacts.push_back(FactMgr.createFact<ExpireFact>(L.ID));
+ CurrentBlockFacts.push_back(FactMgr.createFact<ExpireFact>(
----------------
Xazax-hun wrote:
Random optimization idea to consider for the future: in many cases like end of statement for temporaries or end of scope for locals we have potentially many objects with ending lifetime at the same location. Maybe we do not actually need to create a separate `ExpireFact` for all of them, we could reuse the same fact? Not sure if that could cause any trouble.
https://github.com/llvm/llvm-project/pull/149731
More information about the cfe-commits
mailing list