https://github.com/usx95 updated 
https://github.com/llvm/llvm-project/pull/207519

>From 7224cc565541eb112bd0d838da1d14e26f3a4843 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena <[email protected]>
Date: Sat, 4 Jul 2026 16:17:19 +0000
Subject: [PATCH] [LifetimeSafety][NFC] Update Checker to use prefix comparison
 interfaces

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 
behaviorally identical to `==` (NFC). This prepares the checker to handle 
nested paths (fields and container interiors) in subsequent commits.

TAG=agy
CONV=2cfd8d00-18d7-4a03-8d78-2aba2f9a8f23
---
 clang/lib/Analysis/LifetimeSafety/Checker.cpp    | 6 +++---
 clang/lib/Analysis/LifetimeSafety/MovedLoans.cpp | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Analysis/LifetimeSafety/Checker.cpp 
b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
index 4deead08e6fed..d4405765ceea7 100644
--- a/clang/lib/Analysis/LifetimeSafety/Checker.cpp
+++ b/clang/lib/Analysis/LifetimeSafety/Checker.cpp
@@ -188,9 +188,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))
@@ -223,7 +223,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;

_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to