Refactoring, use early continue in loop
This commit is contained in:
parent
411c5e5f7e
commit
5e618418d5
|
@ -1579,41 +1579,42 @@ void CheckOther::checkIncompleteStatement()
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
|
|
||||||
|
|
||||||
else if (Token::Match(tok, "[;{}] %str%|%num%")) {
|
if (!Token::Match(tok, "[;{}] %str%|%num%"))
|
||||||
// No warning if numeric constant is followed by a "." or ","
|
continue;
|
||||||
if (Token::Match(tok->next(), "%num% [,.]"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// No warning for [;{}] (void *) 0 ;
|
// No warning if numeric constant is followed by a "." or ","
|
||||||
if (Token::Match(tok, "[;{}] 0 ;") && (tok->next()->isCast() || tok->next()->isExpandedMacro()))
|
if (Token::Match(tok->next(), "%num% [,.]"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// bailout if there is a "? :" in this statement
|
// No warning for [;{}] (void *) 0 ;
|
||||||
bool bailout = false;
|
if (Token::Match(tok, "[;{}] 0 ;") && (tok->next()->isCast() || tok->next()->isExpandedMacro()))
|
||||||
for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next()) {
|
continue;
|
||||||
if (tok2->str() == "?") {
|
|
||||||
bailout = true;
|
|
||||||
break;
|
|
||||||
} else if (tok2->str() == ";")
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (bailout)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// no warning if this is the last statement in a ({})
|
// bailout if there is a "? :" in this statement
|
||||||
for (const Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) {
|
bool bailout = false;
|
||||||
if (tok2->str() == "(")
|
for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next()) {
|
||||||
tok2 = tok2->link();
|
if (tok2->str() == "?") {
|
||||||
else if (Token::Match(tok2, "[;{}]")) {
|
bailout = true;
|
||||||
bailout = Token::simpleMatch(tok2, "; } )");
|
break;
|
||||||
break;
|
} else if (tok2->str() == ";")
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
if (bailout)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
constStatementError(tok->next(), tok->next()->isNumber() ? "numeric" : "string");
|
|
||||||
}
|
}
|
||||||
|
if (bailout)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// no warning if this is the last statement in a ({})
|
||||||
|
for (const Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) {
|
||||||
|
if (tok2->str() == "(")
|
||||||
|
tok2 = tok2->link();
|
||||||
|
else if (Token::Match(tok2, "[;{}]")) {
|
||||||
|
bailout = Token::simpleMatch(tok2, "; } )");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bailout)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
constStatementError(tok->next(), tok->next()->isNumber() ? "numeric" : "string");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue