Skip to content

Commit 85df53a

Browse files
committed
ProgramMemory: avoid unnecessary insertion in setValue() [skip ci]
`subexpr` might have been the same as `expr` and thus overwrote the previously added value.
1 parent 3529cd6 commit 85df53a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/programmemory.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ std::size_t ExprIdToken::Hash::operator()(ExprIdToken etok) const
5959
void ProgramMemory::setValue(const Token* expr, const ValueFlow::Value& value) {
6060
copyOnWrite();
6161

62-
(*mValues)[expr] = value;
6362
ValueFlow::Value subvalue = value;
6463
const Token* subexpr = solveExprValue(
6564
expr,
@@ -72,6 +71,8 @@ void ProgramMemory::setValue(const Token* expr, const ValueFlow::Value& value) {
7271
return {};
7372
},
7473
subvalue);
74+
if (expr != subexpr)
75+
(*mValues)[expr] = value;
7576
if (subexpr)
7677
(*mValues)[subexpr] = std::move(subvalue);
7778
}

0 commit comments

Comments
 (0)