Skip to content

Commit 9333d8f

Browse files
authored
[analyzer][NFC] Simplify and eliminate redundant map lookups (#125272)
1 parent fa6b7ec commit 9333d8f

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,7 @@ class SMTConstraintManager : public clang::ento::SimpleConstraintManager {
353353
addStateConstraints(NewState);
354354

355355
std::optional<bool> res = Solver->check();
356-
if (!res)
357-
Cached[hash] = ConditionTruthVal();
358-
else
359-
Cached[hash] = ConditionTruthVal(*res);
360-
361-
return Cached[hash];
356+
return Cached[hash] = res ? ConditionTruthVal(*res) : ConditionTruthVal();
362357
}
363358

364359
// Cache the result of an SMT query (true, false, unknown). The key is the

clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,11 @@ void ExprInspectionChecker::analyzerWarnIfReached(const CallExpr *CE,
227227

228228
void ExprInspectionChecker::analyzerNumTimesReached(const CallExpr *CE,
229229
CheckerContext &C) const {
230-
++ReachedStats[CE].NumTimesReached;
231-
if (!ReachedStats[CE].ExampleNode) {
230+
ReachedStat &Stat = ReachedStats[CE];
231+
++Stat.NumTimesReached;
232+
if (!Stat.ExampleNode) {
232233
// Later, in checkEndAnalysis, we'd throw a report against it.
233-
ReachedStats[CE].ExampleNode = C.generateNonFatalErrorNode();
234+
Stat.ExampleNode = C.generateNonFatalErrorNode();
234235
}
235236
}
236237

0 commit comments

Comments
 (0)