Skip to content

Commit 7920895

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

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/programmemory.cpp

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

48-
ExprIdToken::ExprIdToken(const Token* tok) : tok(tok), exprid(tok ? tok->exprId() : 0) {}
48+
#include <iostream>
49+
50+
ExprIdToken::ExprIdToken(const Token* tok) : tok(tok), exprid(tok ? tok->exprId() : 0)
51+
{
52+
if (!tok)
53+
std::cout << "ExprIdToken - no tok" << std::endl;
54+
}
4955

5056
nonneg int ExprIdToken::getExpressionId() const {
5157
return tok ? tok->exprId() : exprid;
@@ -57,6 +63,12 @@ std::size_t ExprIdToken::Hash::operator()(ExprIdToken etok) const
5763
}
5864

5965
void ProgramMemory::setValue(const Token* expr, const ValueFlow::Value& value) {
66+
if (!expr)
67+
{
68+
std::cout << "setValue - no expr - " << value.toString() << std::endl;
69+
return;
70+
}
71+
6072
copyOnWrite();
6173

6274
(*mValues)[expr] = value;

lib/valueflow.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6309,10 +6309,17 @@ static const Token* parseBinaryIntOp(const Token* expr,
63096309
return varTok;
63106310
}
63116311

6312+
#include <iostream>
6313+
63126314
const Token* ValueFlow::solveExprValue(const Token* expr,
63136315
const std::function<std::vector<MathLib::bigint>(const Token*)>& eval,
63146316
ValueFlow::Value& value)
63156317
{
6318+
if (!expr)
6319+
{
6320+
std::cout << "solveExprValue - no expr" << std::endl;
6321+
return nullptr;
6322+
}
63166323
if (!value.isIntValue() && !value.isIteratorValue() && !value.isSymbolicValue())
63176324
return expr;
63186325
if (value.isSymbolicValue() && !Token::Match(expr, "+|-"))

0 commit comments

Comments
 (0)