Author: Utkarsh Saxena Date: 2026-07-27T10:55:01+02:00 New Revision: ed326421d27ea8c38b11c84aa23bd655063cb4f9
URL: https://github.com/llvm/llvm-project/commit/ed326421d27ea8c38b11c84aa23bd655063cb4f9 DIFF: https://github.com/llvm/llvm-project/commit/ed326421d27ea8c38b11c84aa23bd655063cb4f9.diff LOG: [LifetimeSafety][NFC] Update Checker to use prefix comparison interfaces (#207519) This patch switches the Checker's expiry and invalidation checks to use `AccessPath::isPrefixOf` instead of equality (`==`). Since all generated access paths are currently empty, `isPrefixOf` is behaviourally identical to `==` (NFC). This prepares the checker to handle nested paths (fields and container interiors) in subsequent commits. Added: Modified: clang/lib/Analysis/LifetimeSafety/Checker.cpp clang/lib/Analysis/LifetimeSafety/MovedLoans.cpp Removed: ################################################################################ diff --git a/clang/lib/Analysis/LifetimeSafety/Checker.cpp b/clang/lib/Analysis/LifetimeSafety/Checker.cpp index 380237d890bc8..155c6072a33a5 100644 --- a/clang/lib/Analysis/LifetimeSafety/Checker.cpp +++ b/clang/lib/Analysis/LifetimeSafety/Checker.cpp @@ -190,9 +190,9 @@ class LifetimeChecker { LoanSet HeldLoans = LoanPropagation.getLoans(OID, EF); for (LoanID HeldLoanID : HeldLoans) { const Loan *HeldLoan = FactMgr.getLoanMgr().getLoan(HeldLoanID); - if (ExpiredPath != HeldLoan->getAccessPath()) + if (!ExpiredPath.isPrefixOf(HeldLoan->getAccessPath())) continue; - // HeldLoan is expired because its AccessPath is expired. + // HeldLoan is expired because its base or itself is expired. PendingWarning &CurWarning = FinalWarningsMap[HeldLoan->getID()]; const Expr *MovedExpr = nullptr; if (auto *ME = MovedLoans.getMovedLoans(EF).lookup(HeldLoanID)) @@ -225,7 +225,7 @@ class LifetimeChecker { auto IsInvalidated = [&](const Loan *L) { for (LoanID InvalidID : DirectlyInvalidatedLoans) { const Loan *InvalidL = FactMgr.getLoanMgr().getLoan(InvalidID); - if (InvalidL->getAccessPath() == L->getAccessPath()) + if (InvalidL->getAccessPath().isPrefixOf(L->getAccessPath())) return true; } return false; diff --git a/clang/lib/Analysis/LifetimeSafety/MovedLoans.cpp b/clang/lib/Analysis/LifetimeSafety/MovedLoans.cpp index 138704821024a..1a9ce3e576733 100644 --- a/clang/lib/Analysis/LifetimeSafety/MovedLoans.cpp +++ b/clang/lib/Analysis/LifetimeSafety/MovedLoans.cpp @@ -80,7 +80,7 @@ class AnalysisImpl auto IsInvalidated = [&](const AccessPath &Path) { for (LoanID LID : ImmediatelyMovedLoans) { const Loan *MovedLoan = LoanMgr.getLoan(LID); - if (MovedLoan->getAccessPath() == Path) + if (MovedLoan->getAccessPath().isPrefixOf(Path)) return true; } return false; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
