Move variable declaration to where it's first used

This commit is contained in:
Dmitry-Me 2015-09-16 13:15:07 +03:00
parent d3c629cce9
commit 85d47e25e4
1 changed files with 2 additions and 2 deletions

View File

@ -1229,8 +1229,6 @@ static bool valueFlowForward(Token * const startToken,
++number_of_if;
tok2 = end;
} else {
bool bail = true;
// loop that conditionally set variable and then break => either loop condition is
// redundant or the variable can be unchanged after the loop.
bool loopCondition = false;
@ -1241,6 +1239,8 @@ static bool valueFlowForward(Token * const startToken,
Token::simpleMatch(tok2->next()->astOperand2()->astOperand2(), ";") &&
Token::Match(tok2->next()->astOperand2()->astOperand2()->astOperand1(), "%op%"))
loopCondition = true;
bool bail = true;
if (loopCondition) {
const Token *tok3 = Token::findmatch(start, "%varid%", end, varid);
if (Token::Match(tok3, "%varid% =", varid) &&