[clang] [Analyzer][NFC] Remove redundant function call (PR #75076)
Gábor Spaits via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 11 09:37:16 PST 2023
https://github.com/spaits created https://github.com/llvm/llvm-project/pull/75076
`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.
>From f3d7181073996dd94e6d0b7ac403e9a3d97f4e0d Mon Sep 17 00:00:00 2001
From: Gabor Spaits <gaborspaits1 at gmail.com>
Date: Mon, 11 Dec 2023 16:59:16 +0100
Subject: [PATCH] [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
More information about the cfe-commits
mailing list