use early continue
This commit is contained in:
parent
c0e14d0a5d
commit
31dd4ed787
|
@ -292,22 +292,22 @@ void CheckSizeof::sizeofCalculation()
|
|||
const bool printInconclusive = _settings->inconclusive;
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (Token::simpleMatch(tok, "sizeof (")) {
|
||||
if (!Token::simpleMatch(tok, "sizeof ("))
|
||||
continue;
|
||||
|
||||
// ignore if the `sizeof` result is cast to void inside a macro, i.e. the calculation is
|
||||
// expected to be parsed but skipped, such as in a disabled custom ASSERT() macro
|
||||
if (tok->isExpandedMacro() && tok->previous()) {
|
||||
const Token *cast_end = (tok->previous()->str() == "(") ? tok->previous() : tok;
|
||||
if (Token::simpleMatch(cast_end->tokAt(-3), "( void )") ||
|
||||
Token::simpleMatch(cast_end->previous(), "static_cast<void>")) {
|
||||
continue;
|
||||
}
|
||||
// ignore if the `sizeof` result is cast to void inside a macro, i.e. the calculation is
|
||||
// expected to be parsed but skipped, such as in a disabled custom ASSERT() macro
|
||||
if (tok->isExpandedMacro() && tok->previous()) {
|
||||
const Token *cast_end = (tok->previous()->str() == "(") ? tok->previous() : tok;
|
||||
if (Token::simpleMatch(cast_end->tokAt(-3), "( void )") ||
|
||||
Token::simpleMatch(cast_end->previous(), "static_cast<void>")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const Token *argument = tok->next()->astOperand2();
|
||||
if (argument && argument->isCalculation() && (!argument->isExpandedMacro() || printInconclusive))
|
||||
sizeofCalculationError(argument, argument->isExpandedMacro());
|
||||
}
|
||||
|
||||
const Token *argument = tok->next()->astOperand2();
|
||||
if (argument && argument->isCalculation() && (!argument->isExpandedMacro() || printInconclusive))
|
||||
sizeofCalculationError(argument, argument->isExpandedMacro());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue