[clang] Adding use-after-return in Lifetime Analysis (PR #165370)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 31 11:13:22 PDT 2025


================
@@ -166,7 +169,8 @@ void FactsGenerator::VisitReturnStmt(const ReturnStmt *RS) {
   if (const Expr *RetExpr = RS->getRetValue()) {
     if (hasOrigin(RetExpr)) {
       OriginID OID = FactMgr.getOriginMgr().getOrCreate(*RetExpr);
-      CurrentBlockFacts.push_back(FactMgr.createFact<ReturnOfOriginFact>(OID));
----------------
usx95 wrote:

In that case, I do not think we need a separate fact to represent a `return` which is otherwise a noop for the analysis. The `EscapeOriginFact` can store the relevant information about the expressions and kind of escape (e.g. through fields, global or return) for better diagnositcs.

https://github.com/llvm/llvm-project/pull/165370


More information about the cfe-commits mailing list