From 8b8701d078063d2e0d8f83daa009827706b3fd2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 27 Sep 2019 21:03:47 +0200 Subject: [PATCH] ExprEngine: Cleanup output when variable declaration and initialization is separated --- lib/exprengine.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index 9bcec59dd..67accc942 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -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(data.getNewSymbolName(), tok->variable())); if (Token::Match(tok, "%name% ["))