[clang] [NFC][analyzer] Improve computeObjectUnderConstruction (PR #186186)
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 15 17:37:46 PDT 2026
=?utf-8?q?DonĂ¡t?= Nagy <donat.nagy at ericsson.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/186186 at github.com>
================
@@ -562,8 +562,12 @@ std::optional<SVal> CallEvent::getReturnValueUnderConstruction() const {
EvalCallOptions CallOpts;
ExprEngine &Engine = getState()->getStateManager().getOwningEngine();
+ // FIXME: This code assumes that the _current_ location context and block is
+ // the location and block where this `CallExpr` is called. For a more stable
+ // solution `Engine.getNumVisitedCurrent()` should be replaced with a call to
+ // `Engine.getNumVisited(<CallerLCtx>, <CallerBlock>)`.
----------------
haoNoQ wrote:
Yes I think you're right, this is a bug. We're lucky that our `CallEvent` objects are usually short-lived. But that's definitely a hazard.
This function should always return the same value regardless of the internal state of `ExprEngine`: the actual return location of the call. Regardless of whether the call is about to be evaluated, or in the middle of being evaluated, or has just been evaluated, or has been evaluated a long time ago. Even if simulation is already finished and we're in a `BugReporterVisitor` we should still get the same value every time we call that function. It has to be the actual location that was, or is, or will be used during simulation.
https://github.com/llvm/llvm-project/pull/186186
More information about the cfe-commits
mailing list