Skip to content

Commit e22ec20

Browse files
committed
do not set values if there is no expression [skip ci]
1 parent b067f37 commit e22ec20

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lib/programmemory.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
#include <utility>
4646
#include <vector>
4747

48-
ExprIdToken::ExprIdToken(const Token* tok) : tok(tok), exprid(tok ? tok->exprId() : 0) {}
48+
ExprIdToken::ExprIdToken(const Token* tok) : tok(tok), exprid(tok ? tok->exprId() : 0)
49+
{
50+
assert(tok);
51+
}
4952

5053
nonneg int ExprIdToken::getExpressionId() const {
5154
return tok ? tok->exprId() : exprid;
@@ -57,6 +60,9 @@ std::size_t ExprIdToken::Hash::operator()(ExprIdToken etok) const
5760
}
5861

5962
void ProgramMemory::setValue(const Token* expr, const ValueFlow::Value& value) {
63+
if (!expr)
64+
return;
65+
6066
copyOnWrite();
6167

6268
(*mValues)[expr] = value;

lib/valueflow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6313,6 +6313,8 @@ const Token* ValueFlow::solveExprValue(const Token* expr,
63136313
const std::function<std::vector<MathLib::bigint>(const Token*)>& eval,
63146314
ValueFlow::Value& value)
63156315
{
6316+
if (!expr)
6317+
return nullptr;
63166318
if (!value.isIntValue() && !value.isIteratorValue() && !value.isSymbolicValue())
63176319
return expr;
63186320
if (value.isSymbolicValue() && !Token::Match(expr, "+|-"))

lib/vf_analyzers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
10731073
ProgramState ps;
10741074
for (const auto& p : values) {
10751075
const Variable* var = vars.at(p.first);
1076-
if (!var)
1076+
if (!var || !var->nameToken())
10771077
continue;
10781078
ps[var->nameToken()] = p.second;
10791079
}

0 commit comments

Comments
 (0)