[clang] [LifetimeSafety] Detect use-after-return (PR #165370)
Kashika Akhouri via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 7 00:47:50 PST 2025
================
@@ -112,8 +114,17 @@ class LifetimeChecker {
for (const auto &[LID, Warning] : FinalWarningsMap) {
const Loan &L = FactMgr.getLoanMgr().getLoan(LID);
const Expr *IssueExpr = L.IssueExpr;
- Reporter->reportUseAfterFree(IssueExpr, Warning.UseExpr,
- Warning.ExpiryLoc, Warning.ConfidenceLevel);
+ const Fact *CausingFact = Warning.CausingFact;
+ Confidence Confidence = Warning.ConfidenceLevel;
+ SourceLocation ExpiryLoc = Warning.ExpiryLoc;
+
+ if (const auto *UF = CausingFact->getAs<UseFact>()) {
+ Reporter->reportUseAfterFree(IssueExpr, UF->getUseExpr(), ExpiryLoc,
+ Confidence);
+ } else if (const auto *OEF = CausingFact->getAs<OriginEscapesFact>()) {
----------------
kashika0112 wrote:
Done
https://github.com/llvm/llvm-project/pull/165370
More information about the cfe-commits
mailing list