CheckUninitVar: don't rely on Tokenizer::simplifyKnownVar() to simplify references

This commit is contained in:
Daniel Marjamäki 2015-09-13 17:31:45 +02:00
parent ad007ca2d7
commit ab38ab800e
1 changed files with 8 additions and 2 deletions

View File

@ -828,8 +828,14 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc al
} }
} }
if (alloc == NO_ALLOC && Token::Match(vartok->previous(), "= %name% ;|%cop%")) if (alloc == NO_ALLOC && Token::Match(vartok->previous(), "= %name% ;|%cop%")) {
return true; // taking reference?
const Token *prev = vartok->tokAt(-2);
while (Token::Match(prev, "%name%|*"))
prev = prev->previous();
if (!Token::Match(prev, "&"))
return true;
}
bool unknown = false; bool unknown = false;
if (pointer && CheckNullPointer::isPointerDeRef(vartok, unknown)) { if (pointer && CheckNullPointer::isPointerDeRef(vartok, unknown)) {