55#include " symboldatabase.h"
66#include < algorithm>
77#include < cassert>
8+ #include < memory>
89
910void ProgramMemory::setValue (nonneg int varid, const ValueFlow::Value &value)
1011{
1112 values[varid] = value;
1213}
13-
14- bool ProgramMemory::getIntValue (nonneg int varid, MathLib::bigint* result) const
14+ const ValueFlow::Value* ProgramMemory::getValue (nonneg int varid) const
1515{
1616 const ProgramMemory::Map::const_iterator it = values.find (varid);
17- const bool found = it != values.end () && it->second .isIntValue ();
17+ const bool found = it != values.end () && ! it->second .isImpossible ();
1818 if (found)
19- *result = it->second .intvalue ;
20- return found;
19+ return &it->second ;
20+ else
21+ return nullptr ;
22+ }
23+
24+ bool ProgramMemory::getIntValue (nonneg int varid, MathLib::bigint* result) const
25+ {
26+ const ValueFlow::Value* value = getValue (varid);
27+ if (value && value->isIntValue ()) {
28+ *result = value->intvalue ;
29+ return true ;
30+ }
31+ return false ;
2132}
2233
2334void ProgramMemory::setIntValue (nonneg int varid, MathLib::bigint value)
@@ -27,20 +38,22 @@ void ProgramMemory::setIntValue(nonneg int varid, MathLib::bigint value)
2738
2839bool ProgramMemory::getTokValue (nonneg int varid, const Token** result) const
2940{
30- const ProgramMemory::Map::const_iterator it = values.find (varid);
31- const bool found = it != values.end () && it->second .isTokValue ();
32- if (found)
33- *result = it->second .tokvalue ;
34- return found;
41+ const ValueFlow::Value* value = getValue (varid);
42+ if (value && value->isTokValue ()) {
43+ *result = value->tokvalue ;
44+ return true ;
45+ }
46+ return false ;
3547}
3648
3749bool ProgramMemory::getContainerSizeValue (nonneg int varid, MathLib::bigint* result) const
3850{
39- const ProgramMemory::Map::const_iterator it = values.find (varid);
40- const bool found = it != values.end () && it->second .isContainerSizeValue ();
41- if (found)
42- *result = it->second .intvalue ;
43- return found;
51+ const ValueFlow::Value* value = getValue (varid);
52+ if (value && value->isContainerSizeValue ()) {
53+ *result = value->intvalue ;
54+ return true ;
55+ }
56+ return false ;
4457}
4558
4659void ProgramMemory::setUnknown (nonneg int varid)
0 commit comments