Verification; Fixed false negative when global variable is changed by function call
This commit is contained in:
parent
2137f1ead9
commit
84b4f0f6ab
|
@ -165,7 +165,7 @@ namespace {
|
||||||
, callbacks(callbacks)
|
, callbacks(callbacks)
|
||||||
, mTrackExecution(trackExecution)
|
, mTrackExecution(trackExecution)
|
||||||
, mDataIndex(trackExecution->getNewDataIndex()) {}
|
, mDataIndex(trackExecution->getNewDataIndex()) {}
|
||||||
typedef std::map<nonneg int, std::shared_ptr<ExprEngine::Value>> Memory;
|
typedef std::map<nonneg int, ExprEngine::ValuePtr> Memory;
|
||||||
Memory memory;
|
Memory memory;
|
||||||
int * const symbolValueIndex;
|
int * const symbolValueIndex;
|
||||||
const Tokenizer * const tokenizer;
|
const Tokenizer * const tokenizer;
|
||||||
|
@ -198,6 +198,19 @@ namespace {
|
||||||
structVal->member[memberName] = value;
|
structVal->member[memberName] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void functionCall() {
|
||||||
|
// Remove values for global variables
|
||||||
|
const SymbolDatabase *symbolDatabase = tokenizer->getSymbolDatabase();
|
||||||
|
for (std::map<nonneg int, ExprEngine::ValuePtr>::iterator it = memory.begin(); it != memory.end();) {
|
||||||
|
unsigned int varid = it->first;
|
||||||
|
const Variable *var = symbolDatabase->getVariableFromVarId(varid);
|
||||||
|
if (var->isGlobal())
|
||||||
|
it = memory.erase(it);
|
||||||
|
else
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string getNewSymbolName() OVERRIDE {
|
std::string getNewSymbolName() OVERRIDE {
|
||||||
return "$" + std::to_string(++(*symbolValueIndex));
|
return "$" + std::to_string(++(*symbolValueIndex));
|
||||||
}
|
}
|
||||||
|
@ -1181,6 +1194,7 @@ static ExprEngine::ValuePtr executeFunctionCall(const Token *tok, Data &data)
|
||||||
|
|
||||||
auto val = getValueRangeFromValueType(data.getNewSymbolName(), tok->valueType(), *data.settings);
|
auto val = getValueRangeFromValueType(data.getNewSymbolName(), tok->valueType(), *data.settings);
|
||||||
call(data.callbacks, tok, val, &data);
|
call(data.callbacks, tok, val, &data);
|
||||||
|
data.functionCall();
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue