https://github.com/spaits updated https://github.com/llvm/llvm-project/pull/75076
From f3d7181073996dd94e6d0b7ac403e9a3d97f4e0d Mon Sep 17 00:00:00 2001 From: Gabor Spaits <gaborspai...@gmail.com> Date: Mon, 11 Dec 2023 16:59:16 +0100 Subject: [PATCH 1/2] [Analyzer][NFC] Remove redundant function call PRValueHandler's handle function is only called from Tracker's track function. In Tracker::track the ExprNode parameter passed to PRValueHandler::handle is already the ExplodedNode for the tracked expression. We do not need to calculate that again. --- .../lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index 4a9d130c240aec..4a1607530dbd82 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -2565,21 +2565,17 @@ 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 {}; 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 From d3b3bbce9ee6fa107c6bfa183dd7885f191300d6 Mon Sep 17 00:00:00 2001 From: Gabor Spaits <gaborspai...@gmail.com> Date: Mon, 11 Dec 2023 19:14:36 +0100 Subject: [PATCH 2/2] Add assertion to check if RVNode node for E --- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index 4a1607530dbd82..745a9f34f6a61d 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -2567,6 +2567,8 @@ class PRValueHandler final : public ExpressionHandler { Tracker::Result handle(const Expr *E, const ExplodedNode *InputNode, const ExplodedNode *RVNode, TrackingOptions Opts) override { + assert(RVNode->getStmtForDiagnostics() == E && "RVNode must be the ExplodedNode for the tracked expression."); + if (!E->isPRValue() || !RVNode) return {}; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits