[clang] [NFC][analyzer] Spread use of 'Expr*' instead of 'Stmt*' (PR #188319)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 30 02:12:11 PDT 2026


================
@@ -297,17 +297,19 @@ void ExprEngine::processCallExit(ExplodedNode *CEBNode) {
   if (CE) {
     if (const ReturnStmt *RS = dyn_cast_or_null<ReturnStmt>(LastSt)) {
       const LocationContext *LCtx = CEBNode->getLocationContext();
+      // FIXME: This tries to look up the return statement in the environment,
+      // which is special cased to look up the subexpression RS->getRetValue()
+      // in environment. Instead of relying on this hack, pass
+      // RS->getRetValue() to getSVal() after checking it for nullness.
----------------
steakhal wrote:

I think the engine should just look into what CallExpr made us to the current function and bind our return value directly there - basically shortcuting what we probably already use the return statement for.
However, it might not be that easy if there is some internal invariant about the order of operations around returning from a function; thus we would need to be extra careful changing any of this. Especially with analyzing C++, RVO, NRVO, guard object dtors.

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


More information about the cfe-commits mailing list