CheckNullPointer: Reuse CheckNullPointer::isPointerDeRef in CheckNullPointer::nullPointerByDeRefAndChec

This commit is contained in:
Daniel Marjamäki 2010-10-31 16:07:50 +01:00
parent 32def3a3f0
commit 69c6358198
1 changed files with 3 additions and 7 deletions

View File

@ -112,7 +112,7 @@ bool CheckNullPointer::isPointerDeRef(const Token *tok, bool &unknown)
unknown = false;
// Dereferencing pointer..
if (Token::Match(tok->tokAt(-2), "[;{}=+-/(,] * %var%"))
if (Token::Match(tok->tokAt(-3), "!!sizeof [;{}=+-/(,] * %var%"))
return true;
if (!Token::simpleMatch(tok->tokAt(-2), "& (") && Token::Match(tok->next(), ". %var%"))
@ -401,7 +401,8 @@ void CheckNullPointer::nullPointerByDeRefAndChec()
{
if (tok1->varId() == varid)
{
if (Token::Match(tok1->tokAt(-2), "[=;{}] *"))
bool unknown = false;
if (CheckNullPointer::isPointerDeRef(tok1, unknown))
{
nullPointerError(tok1, varname, tok->linenr());
break;
@ -414,11 +415,6 @@ void CheckNullPointer::nullPointerByDeRefAndChec()
{
break;
}
// dereference in function call
else if (Token::Match(tok1->tokAt(-3), "!!sizeof [(,] *"))
{
nullPointerError(tok1, varname, tok->linenr());
}
}
else if (tok1->str() == "{" ||