From 31dd4ed7871427764a1cb954f81d2e9e76cbdb55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 12 Mar 2018 12:50:33 +0100 Subject: [PATCH] use early continue --- lib/checksizeof.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/checksizeof.cpp b/lib/checksizeof.cpp index 9a59c68e2..603264789 100644 --- a/lib/checksizeof.cpp +++ b/lib/checksizeof.cpp @@ -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")) { - 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")) { + 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()); } }