removed some redundant null pointer checks before calling Token::Match
This commit is contained in:
parent
53b58f0ed9
commit
29a49d0641
|
@ -2608,7 +2608,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess)
|
||||||
if (tok && isVariableDeclaration(tok, vartok, typetok)) {
|
if (tok && isVariableDeclaration(tok, vartok, typetok)) {
|
||||||
// If the vartok was set in the if-blocks above, create a entry for this variable..
|
// If the vartok was set in the if-blocks above, create a entry for this variable..
|
||||||
tok = vartok->next();
|
tok = vartok->next();
|
||||||
while (tok && Token::Match(tok, "[|{"))
|
while (Token::Match(tok, "[|{"))
|
||||||
tok = tok->link()->next();
|
tok = tok->link()->next();
|
||||||
|
|
||||||
if (vartok->varId() == 0) {
|
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
|
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;
|
return false;
|
||||||
|
|
||||||
const Token* localTypeTok = skipScopeIdentifiers(tok);
|
const Token* localTypeTok = skipScopeIdentifiers(tok);
|
||||||
|
|
|
@ -285,9 +285,9 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Function pointer or prototype..
|
// Function pointer or prototype..
|
||||||
while (tok && Token::Match(tok, "(|[")) {
|
while (Token::Match(tok, "(|[")) {
|
||||||
tok = tok->link()->next();
|
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();
|
tok = tok->next();
|
||||||
}
|
}
|
||||||
if (!tok)
|
if (!tok)
|
||||||
|
|
|
@ -1524,7 +1524,7 @@ void Tokenizer::simplifyMulAndParens()
|
||||||
}
|
}
|
||||||
if (!tokend || !(tokend->isAssignmentOp()))
|
if (!tokend || !(tokend->isAssignmentOp()))
|
||||||
continue;
|
continue;
|
||||||
while (tokbegin && (Token::Match(tokbegin, "&|("))) {
|
while (Token::Match(tokbegin, "&|(")) {
|
||||||
if (tokbegin->str() == "&") {
|
if (tokbegin->str() == "&") {
|
||||||
if (Token::Match(tokbegin->tokAt(-2), "[;{}&(] *")) {
|
if (Token::Match(tokbegin->tokAt(-2), "[;{}&(] *")) {
|
||||||
//remove '* &'
|
//remove '* &'
|
||||||
|
|
|
@ -511,7 +511,7 @@ static void compileTerm(Token *&tok, AST_state& state)
|
||||||
return;
|
return;
|
||||||
if (Token::Match(tok, "L %str%|%char%"))
|
if (Token::Match(tok, "L %str%|%char%"))
|
||||||
tok = tok->next();
|
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();
|
tok = tok->next();
|
||||||
|
|
||||||
if (tok->isLiteral()) {
|
if (tok->isLiteral()) {
|
||||||
|
|
|
@ -260,7 +260,7 @@ static bool isVariableChanged(const Token *start, const Token *end, const unsign
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const Token *parent = tok->astParent();
|
const Token *parent = tok->astParent();
|
||||||
while (parent && Token::Match(parent, ".|::"))
|
while (Token::Match(parent, ".|::"))
|
||||||
parent = parent->astParent();
|
parent = parent->astParent();
|
||||||
if (parent && parent->type() == Token::eIncDecOp)
|
if (parent && parent->type() == Token::eIncDecOp)
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue