Skip to content

Commit

Permalink
programmemory.cpp: avoid calls to non-const at()
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Aug 2, 2024
1 parent 840cdfe commit d738117
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/programmemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ namespace {
ValueFlow::Value executeMultiCondition(bool b, const Token* expr)
{
if (pm->hasValue(expr->exprId())) {
const ValueFlow::Value& v = pm->at(expr->exprId());
const ValueFlow::Value& v = utils::as_const(*pm).at(expr->exprId());
if (v.isIntValue())
return v;
}
Expand Down Expand Up @@ -1577,7 +1577,7 @@ namespace {
return execute(expr->astOperand1());
}
if (expr->exprId() > 0 && pm->hasValue(expr->exprId())) {
ValueFlow::Value result = pm->at(expr->exprId());
ValueFlow::Value result = utils::as_const(*pm).at(expr->exprId());
if (result.isImpossible() && result.isIntValue() && result.intvalue == 0 && isUsedAsBool(expr, *settings)) {
result.intvalue = !result.intvalue;
result.setKnown();
Expand Down Expand Up @@ -1693,7 +1693,7 @@ namespace {
if (!expr)
return v;
if (expr->exprId() > 0 && pm->hasValue(expr->exprId())) {
if (updateValue(v, pm->at(expr->exprId())))
if (updateValue(v, utils::as_const(*pm).at(expr->exprId())))
return v;
}
// Find symbolic values
Expand All @@ -1704,7 +1704,7 @@ namespace {
continue;
if (value.tokvalue->exprId() > 0 && !pm->hasValue(value.tokvalue->exprId()))
continue;
ValueFlow::Value v2 = pm->at(value.tokvalue->exprId());
ValueFlow::Value v2 = utils::as_const(*pm).at(value.tokvalue->exprId());
if (!v2.isIntValue() && value.intvalue != 0)
continue;
v2.intvalue += value.intvalue;
Expand Down

0 comments on commit d738117

Please sign in to comment.