Merge pull request #684 from Dmitry-Me/moveDeclaration
Move variable declaration to where it's first used
This commit is contained in:
commit
66f1d9d680
|
@ -1229,8 +1229,6 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
++number_of_if;
|
++number_of_if;
|
||||||
tok2 = end;
|
tok2 = end;
|
||||||
} else {
|
} else {
|
||||||
bool bail = true;
|
|
||||||
|
|
||||||
// loop that conditionally set variable and then break => either loop condition is
|
// loop that conditionally set variable and then break => either loop condition is
|
||||||
// redundant or the variable can be unchanged after the loop.
|
// redundant or the variable can be unchanged after the loop.
|
||||||
bool loopCondition = false;
|
bool loopCondition = false;
|
||||||
|
@ -1241,6 +1239,8 @@ static bool valueFlowForward(Token * const startToken,
|
||||||
Token::simpleMatch(tok2->next()->astOperand2()->astOperand2(), ";") &&
|
Token::simpleMatch(tok2->next()->astOperand2()->astOperand2(), ";") &&
|
||||||
Token::Match(tok2->next()->astOperand2()->astOperand2()->astOperand1(), "%op%"))
|
Token::Match(tok2->next()->astOperand2()->astOperand2()->astOperand1(), "%op%"))
|
||||||
loopCondition = true;
|
loopCondition = true;
|
||||||
|
|
||||||
|
bool bail = true;
|
||||||
if (loopCondition) {
|
if (loopCondition) {
|
||||||
const Token *tok3 = Token::findmatch(start, "%varid%", end, varid);
|
const Token *tok3 = Token::findmatch(start, "%varid%", end, varid);
|
||||||
if (Token::Match(tok3, "%varid% =", varid) &&
|
if (Token::Match(tok3, "%varid% =", varid) &&
|
||||||
|
|
Loading…
Reference in New Issue