ExprEngine: Cleanup output when variable declaration and initialization is separated

This commit is contained in:
Daniel Marjamäki 2019-09-27 21:03:47 +02:00
parent 398cfc1f5a
commit 8b8701d078
1 changed files with 5 additions and 1 deletions

View File

@ -229,7 +229,7 @@ namespace {
return;
const SymbolDatabase * const symbolDatabase = tokenizer->getSymbolDatabase();
std::ostringstream s;
s << "{"; // << dataIndex << ":";
s << "{"; // << mDataIndex << ":";
for (auto mem : memory) {
ExprEngine::ValuePtr value = mem.second;
const Variable *var = symbolDatabase->getVariableFromVarId(mem.first);
@ -967,6 +967,10 @@ static void execute(const Token *start, const Token *end, Data &data)
if (Token::Match(tok, "[;{}]"))
data.trackProgramState(tok);
if (tok->variable() && tok->variable()->nameToken() == tok) {
if (Token::Match(tok, "%varid% ; %varid% =", tok->varId())) {
tok = tok->tokAt(2);
continue;
}
if (tok->variable()->isArray()) {
data.assignValue(tok, tok->varId(), std::make_shared<ExprEngine::ArrayValue>(data.getNewSymbolName(), tok->variable()));
if (Token::Match(tok, "%name% ["))