refactoring, use early continue in for loop

This commit is contained in:
Daniel Marjamäki 2017-06-30 12:45:48 +02:00
parent 15b0eb42bd
commit 3ab8466415
1 changed files with 61 additions and 58 deletions

View File

@ -763,7 +763,17 @@ bool CheckUninitVar::checkLoopBody(const Token *tok, const Variable& var, const
assert(tok->str() == "{");
for (const Token * const end = tok->link(); tok != end; tok = tok->next()) {
if (tok->varId() == var.declarationId()) {
if (Token::Match(tok, "sizeof|typeof (")) {
tok = tok->next()->link();
continue;
}
if (Token::Match(tok, "asm ( %str% ) ;"))
return true;
if (tok->varId() != var.declarationId())
continue;
if (!membervar.empty()) {
if (isMemberVariableAssignment(tok, membervar)) {
bool assign = true;
@ -820,13 +830,6 @@ bool CheckUninitVar::checkLoopBody(const Token *tok, const Variable& var, const
}
}
if (Token::Match(tok, "sizeof|typeof ("))
tok = tok->next()->link();
if (Token::Match(tok, "asm ( %str% ) ;"))
return true;
}
if (!suppressErrors && usetok) {
if (membervar.empty())
uninitvarError(usetok, usetok->str(), alloc);