Fixed: (warning) Found simple pattern inside Token::Match() call.

This commit is contained in:
Edoardo Prezioso 2012-01-28 20:31:12 +01:00
parent 91a01a0a0d
commit bb703f4d0b
3 changed files with 6 additions and 6 deletions

View File

@ -1036,7 +1036,7 @@ void CheckNullPointer::nullConstantDereference()
nullPointerError(*it);
}
}
} else if (Token::Match(tok, "std :: string ( 0 )"))
} else if (Token::simpleMatch(tok, "std :: string ( 0 )"))
nullPointerError(tok);
else if (Token::Match(tok, "%var% ( 0 )")) {
const Variable* var = symbolDatabase->getVariableFromVarId(tok->varId());

View File

@ -1706,7 +1706,7 @@ void CheckOther::checkUnsignedDivision()
if ((isUnsigned(var1) && isSigned(var2)) || (isUnsigned(var2) && isSigned(var1))) {
udivError(tok->next(), true);
}
} else if (!ifTok && Token::Match(tok, "if ("))
} else if (!ifTok && Token::simpleMatch(tok, "if ("))
ifTok = tok->next()->link()->next()->link();
else if (ifTok == tok)
ifTok = 0;
@ -2534,12 +2534,12 @@ void CheckOther::checkDoubleFree()
else if (Token::Match(tok, "%var% (") && !Token::Match(tok, "printf|sprintf|snprintf|fprintf|if|while")) {
// If this is a new function definition, clear all variables
if (Token::Match(tok->next()->link(), ") {")) {
if (Token::simpleMatch(tok->next()->link(), ") {")) {
freedVariables.clear();
closeDirVariables.clear();
}
// If it is a function call, then clear those variables in its argument list
else if (Token::Match(tok->next()->link(), ") ;")) {
else if (Token::simpleMatch(tok->next()->link(), ") ;")) {
for (const Token* tok2 = tok->tokAt(2); tok2 != tok->linkAt(1); tok2 = tok2->next()) {
if (Token::Match(tok2, "%var%")) {
unsigned int var = tok2->varId();

View File

@ -3854,9 +3854,9 @@ void Tokenizer::simplifyRealloc()
tok = tok->link();
else if (Token::Match(tok, "[;{}] %var% = realloc (")) {
tok = tok->tokAt(3);
if (Token::Match(tok->next(), "( 0 ,")) {
if (Token::simpleMatch(tok->next(), "( 0 ,")) {
//no "x = realloc(0,);"
if (!Token::Match(tok->next()->link(), ") ;") || tok->next()->link()->previous() == tok->tokAt(3))
if (!Token::simpleMatch(tok->next()->link(), ") ;") || tok->next()->link()->previous() == tok->tokAt(3))
continue;
// delete "0 ,"