================
@@ -557,14 +558,22 @@ class LifetimeChecker {
/// Given a chain of origins that shows how a loan propagates, this function
/// extracts the corresponding expressions for each origin. Origins that
refer
/// to declarations (rather than expressions) are skipped.
+ ///
+ /// Until the chain reaches a declaration it is inside the use expression,
+ /// where casts just load the used variable.
llvm::SmallVector<const Expr *>
getExprChain(llvm::ArrayRef<OriginID> OriginFlowChain) {
- llvm::SmallVector<const Expr *> rs;
- for (const OriginID CurrOID : OriginFlowChain)
- if (const Expr *CurrExpr =
- FactMgr.getOriginMgr().getOrigin(CurrOID).getExpr())
- rs.push_back(CurrExpr);
- return rs;
+ llvm::SmallVector<const Expr *> Chain;
+ bool InUse = true;
+ for (const OriginID CurrOID : OriginFlowChain) {
+ const Expr *CurrExpr =
+ FactMgr.getOriginMgr().getOrigin(CurrOID).getExpr();
+ if (!CurrExpr)
+ InUse = false;
+ else if (!InUse || !isa<ImplicitCastExpr>(CurrExpr))
+ Chain.push_back(CurrExpr);
+ }
+ return Chain;
}
----------------
Xazax-hun wrote:
I moved it over to `buildOriginFlowChain`. If you still prefer it to be in a
separate PR, I can look into it.
https://github.com/llvm/llvm-project/pull/225799
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits