removed some redundant null pointer checks before calling Token::Match

This commit is contained in:
Daniel Marjamäki 2014-09-14 11:35:04 +02:00
parent 53b58f0ed9
commit 29a49d0641
5 changed files with 7 additions and 7 deletions

View File

@ -2608,7 +2608,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess)
if (tok && isVariableDeclaration(tok, vartok, typetok)) {
// If the vartok was set in the if-blocks above, create a entry for this variable..
tok = vartok->next();
while (tok && Token::Match(tok, "[|{"))
while (Token::Match(tok, "[|{"))
tok = tok->link()->next();
if (vartok->varId() == 0) {
@ -2681,7 +2681,7 @@ static const Token* skipPointers(const Token* tok)
bool Scope::isVariableDeclaration(const Token* tok, const Token*& vartok, const Token*& typetok) const
{
if (tok && check && check->_tokenizer->isCPP() && Token::Match(tok, "throw|new"))
if (check && check->_tokenizer->isCPP() && Token::Match(tok, "throw|new"))
return false;
const Token* localTypeTok = skipScopeIdentifiers(tok);

View File

@ -285,9 +285,9 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
return 0;
// Function pointer or prototype..
while (tok && Token::Match(tok, "(|[")) {
while (Token::Match(tok, "(|[")) {
tok = tok->link()->next();
while (tok && Token::Match(tok, "const|volatile")) // Ticket #5786: Skip function cv-qualifiers
while (Token::Match(tok, "const|volatile")) // Ticket #5786: Skip function cv-qualifiers
tok = tok->next();
}
if (!tok)

View File

@ -1524,7 +1524,7 @@ void Tokenizer::simplifyMulAndParens()
}
if (!tokend || !(tokend->isAssignmentOp()))
continue;
while (tokbegin && (Token::Match(tokbegin, "&|("))) {
while (Token::Match(tokbegin, "&|(")) {
if (tokbegin->str() == "&") {
if (Token::Match(tokbegin->tokAt(-2), "[;{}&(] *")) {
//remove '* &'

View File

@ -511,7 +511,7 @@ static void compileTerm(Token *&tok, AST_state& state)
return;
if (Token::Match(tok, "L %str%|%char%"))
tok = tok->next();
if (state.inArrayAssignment && tok->str() == "." && Token::Match(tok->tokAt(-1), ",|{")) // Jump over . in C style struct initialization
if (state.inArrayAssignment && tok->str() == "." && Token::Match(tok->previous(), ",|{")) // Jump over . in C style struct initialization
tok = tok->next();
if (tok->isLiteral()) {

View File

@ -260,7 +260,7 @@ static bool isVariableChanged(const Token *start, const Token *end, const unsign
return true;
const Token *parent = tok->astParent();
while (parent && Token::Match(parent, ".|::"))
while (Token::Match(parent, ".|::"))
parent = parent->astParent();
if (parent && parent->type() == Token::eIncDecOp)
return true;