MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / setValue

Method setValue

lib/programmemory.cpp:66–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void ProgramMemory::setValue(const Token* expr, const ValueFlow::Value& value) {
67 if (!expr)
68 return;
69
70 copyOnWrite();
71
72 ValueFlow::Value subvalue = value;
73 const Token* subexpr = solveExprValue(
74 expr,
75 [&](const Token* tok) -> std::vector<MathLib::bigint> {
76 if (const ValueFlow::Value* v = tok->getKnownValue(ValueFlow::Value::ValueType::INT))
77 return {v->intvalue};
78 MathLib::bigint result = 0;
79 if (getIntValue(tok->exprId(), result))
80 return {result};
81 return {};
82 },
83 subvalue);
84 if (expr != subexpr)
85 (*mValues)[expr] = value;
86 if (subexpr)
87 (*mValues)[subexpr] = std::move(subvalue);
88}
89
90const ValueFlow::Value* ProgramMemory::getValue(nonneg int exprid, bool impossible) const
91{

Callers 8

fillFromPathMethod · 0.45
valueFlowFunctionReturnFunction · 0.45
addVarsFunction · 0.45
getProgramMemoryFunction · 0.45
executeImplMethod · 0.45
evaluateLibraryFunctionFunction · 0.45

Calls 2

solveExprValueFunction · 0.85
getKnownValueMethod · 0.80

Tested by

no test coverage detected