diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index 4a9d130c240ae..4dbbd2024577e 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -2565,21 +2565,21 @@ class PRValueHandler final : public ExpressionHandler { using ExpressionHandler::ExpressionHandler; Tracker::Result handle(const Expr *E, const ExplodedNode *InputNode, - const ExplodedNode *ExprNode, + const ExplodedNode *RVNode, TrackingOptions Opts) override { - if (!E->isPRValue()) - return {}; - const ExplodedNode *RVNode = findNodeForExpression(ExprNode, E); - if (!RVNode) + if (!E->isPRValue() || !RVNode) return {}; + assert(RVNode->getStmtForDiagnostics() == E && + "RVNode must be the ExplodedNode for the tracked expression."); + Tracker::Result CombinedResult; Tracker &Parent = getParentTracker(); - const auto track = [&CombinedResult, &Parent, ExprNode, + const auto track = [&CombinedResult, &Parent, RVNode, Opts](const Expr *Inner) { - CombinedResult.combineWith(Parent.track(Inner, ExprNode, Opts)); + CombinedResult.combineWith(Parent.track(Inner, RVNode, Opts)); }; // FIXME: Initializer lists can appear in many different contexts