================
@@ -260,10 +260,26 @@ class LifetimeChecker {
             SemaHelper->reportUseAfterInvalidation(
                 InvalidatedPVD, UF->getUseExpr(), Warning.InvalidatedByExpr);
 
-        } else
+        } else {
           // Scope-based expiry (use-after-scope).
+
+          llvm::SmallVector<OriginID> OriginFlowChain;
+
+          for (const OriginList *Cur = UF->getUsedOrigins(); Cur;
+               Cur = Cur->peelOuterOrigin())
+            if (LoanPropagation.getLoans(Cur->getOuterOriginID(), UF)
+                    .contains(LID)) {
+              OriginFlowChain = LoanPropagation.buildOriginFlowChain(
+                  FactMgr, UF, Cur->getOuterOriginID(), LID);
----------------
usx95 wrote:

> LoanPropagation.buildOriginFlowChain(FactMgr,

I might have missed this in the earlier PR. `buildOriginFlowChain` does not 
need the `FactMgr` input here. The `LoanPropagation` construct already accepts 
an instance of `FactMgr`. We can persist that as a field.

```cpp
LoanPropagationAnalysis::LoanPropagationAnalysis(
    const CFG &C, AnalysisDeclContext &AC, FactManager &F,
    OriginLoanMap::Factory &OriginLoanMapFactory,
    LoanSet::Factory &LoanSetFactory)
    : PImpl(std::make_unique<Impl>(C, AC, F, OriginLoanMapFactory,
                                   LoanSetFactory)) {
  PImpl->run();
}
```

But this belongs to a separate PR.

https://github.com/llvm/llvm-project/pull/199345
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to