[clang] [LifetimeSafety] Add support for tracking non-trivially destructed temporary objects (PR #172007)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 15 05:08:24 PST 2025
================
@@ -233,13 +261,38 @@ void FactsGenerator::handleLifetimeEnds(const CFGLifetimeEnds &LifetimeEnds) {
if (const auto *BL = dyn_cast<PathLoan>(Loan)) {
// Check if the loan is for a stack variable and if that variable
// is the one being destructed.
- if (BL->getAccessPath().D == LifetimeEndsVD)
+ const AccessPath AP = BL->getAccessPath();
+ const ValueDecl *Path = AP.getAsValueDecl();
+ if (Path == LifetimeEndsVD)
CurrentBlockFacts.push_back(FactMgr.createFact<ExpireFact>(
BL->getID(), LifetimeEnds.getTriggerStmt()->getEndLoc()));
}
}
}
+void FactsGenerator::handleTemporaryDtor(
+ const CFGTemporaryDtor &TemporaryDtor) {
+ const CXXBindTemporaryExpr *BTE = TemporaryDtor.getBindTemporaryExpr();
----------------
usx95 wrote:
nit: rename to `ExpiringBTE`
https://github.com/llvm/llvm-project/pull/172007
More information about the cfe-commits
mailing list