CheckNullPointer: Reuse the CheckNullPointer::isPointerDeRef function

This commit is contained in:
Daniel Marjamäki 2010-10-31 15:46:08 +01:00
parent 33d3fd4716
commit 32def3a3f0
1 changed files with 7 additions and 1 deletions

View File

@ -127,6 +127,11 @@ bool CheckNullPointer::isPointerDeRef(const Token *tok, bool &unknown)
if (Token::Match(tok, "%var% ("))
return true;
if (Token::Match(tok, "%var% = %var% .") &&
tok->varId() > 0 &&
tok->varId() == tok->tokAt(2)->varId())
return true;
// Not a dereference..
if (Token::Match(tok->previous(), "[;{}] %var% ="))
return false;
@ -176,7 +181,8 @@ void CheckNullPointer::nullPointerAfterLoop()
if (tok2->varId() == varid)
{
if (tok2->next()->str() == "." || Token::Match(tok2->next(), "= %varid% .", varid))
bool unknown = false;
if (CheckNullPointer::isPointerDeRef(tok2, unknown))
{
// Is this variable a pointer?
const Token *tok3 = Token::findmatch(_tokenizer->tokens(), "%type% * %varid% [;)=]", varid);