Better variable name

This commit is contained in:
Dmitry-Me 2020-02-18 18:38:59 +03:00
parent 2a16e8d4c1
commit 2168305f4e
1 changed files with 3 additions and 5 deletions

View File

@ -873,8 +873,7 @@ bool CheckUninitVar::checkLoopBody(const Token *tok, const Variable& var, const
if (isVariableUsage(tok, var.isPointer(), alloc)) if (isVariableUsage(tok, var.isPointer(), alloc))
usetok = tok; usetok = tok;
else if (tok->strAt(1) == "=") { else if (tok->strAt(1) == "=") {
// Is var used in rhs? bool varIsUsedInRhs = false;
bool rhs = false;
std::stack<const Token *> tokens; std::stack<const Token *> tokens;
tokens.push(tok->next()->astOperand2()); tokens.push(tok->next()->astOperand2());
while (!tokens.empty()) { while (!tokens.empty()) {
@ -883,8 +882,7 @@ bool CheckUninitVar::checkLoopBody(const Token *tok, const Variable& var, const
if (!t) if (!t)
continue; continue;
if (t->varId() == var.declarationId()) { if (t->varId() == var.declarationId()) {
// var is used in rhs varIsUsedInRhs = true;
rhs = true;
break; break;
} }
if (Token::simpleMatch(t->previous(),"sizeof (")) if (Token::simpleMatch(t->previous(),"sizeof ("))
@ -892,7 +890,7 @@ bool CheckUninitVar::checkLoopBody(const Token *tok, const Variable& var, const
tokens.push(t->astOperand1()); tokens.push(t->astOperand1());
tokens.push(t->astOperand2()); tokens.push(t->astOperand2());
} }
if (!rhs) if (!varIsUsedInRhs)
return true; return true;
} else { } else {
return true; return true;