[clang] 59ac9a2 - [analyzer] Improve node creation hygiene in MPIChecker (#238423)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 05:12:05 PST 2026
Author: DonĂ¡t Nagy
Date: 2026-11-04T14:12:00+01:00
New Revision: 59ac9a287714722a0535f30f45fd11c28793d240
URL: https://github.com/llvm/llvm-project/commit/59ac9a287714722a0535f30f45fd11c28793d240
DIFF: https://github.com/llvm/llvm-project/commit/59ac9a287714722a0535f30f45fd11c28793d240.diff
LOG: [analyzer] Improve node creation hygiene in MPIChecker (#238423)
Properly handle the case when node creation fails, remove a pointless
transition and some pointless state lookups.
Fixes #64647
Added:
Modified:
clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
index 2932cc1336571c..d5e862a918a35f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
@@ -43,9 +43,10 @@ void MPIChecker::checkDoubleNonblocking(const CallEvent &PreCallEvent,
// double nonblocking detected
if (Req && Req->CurrentState == Request::State::Nonblocking) {
ExplodedNode *ErrorNode = Ctx.generateNonFatalErrorNode();
+ if (!ErrorNode)
+ return;
BReporter.reportDoubleNonblocking(PreCallEvent, *Req, MR, ErrorNode,
Ctx.getBugReporter());
- Ctx.addTransition(ErrorNode->getState(), ErrorNode);
}
// no error
else {
@@ -80,10 +81,10 @@ void MPIChecker::checkUnmatchedWaits(const CallEvent &PreCallEvent,
const Request *const Req = State->get<RequestMap>(ReqRegion);
State = State->set<RequestMap>(ReqRegion, Request::State::Wait);
if (!Req) {
- if (!ErrorNode) {
+ if (!ErrorNode)
ErrorNode = Ctx.generateNonFatalErrorNode(State);
- State = ErrorNode->getState();
- }
+ if (!ErrorNode)
+ continue;
// A wait has no matching nonblocking call.
BReporter.reportUnmatchedWait(PreCallEvent, ReqRegion, ErrorNode,
Ctx.getBugReporter());
@@ -110,11 +111,10 @@ void MPIChecker::checkMissingWaits(SymbolReaper &SymReaper,
for (const auto &Req : ReqMap) {
if (!SymReaper.isLiveRegion(Req.first)) {
if (Req.second.CurrentState == Request::State::Nonblocking) {
-
- if (!ErrorNode) {
+ if (!ErrorNode)
ErrorNode = Ctx.generateNonFatalErrorNode(State);
- State = ErrorNode->getState();
- }
+ if (!ErrorNode)
+ continue;
BReporter.reportMissingWait(Req.second, Req.first, ErrorNode,
Ctx.getBugReporter());
}
More information about the cfe-commits
mailing list