convert CheckClass::noMemset to use new variable lookup capability

This commit is contained in:
Robert Reif 2011-02-26 16:00:05 -05:00
parent 8152cbbd1b
commit 31a18b9b23
1 changed files with 5 additions and 8 deletions

View File

@ -695,6 +695,8 @@ void CheckClass::unusedPrivateFunctionError(const Token *tok, const std::string
void CheckClass::noMemset()
{
createSymbolDatabase();
// Locate all 'memset' tokens..
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
{
@ -715,14 +717,9 @@ void CheckClass::noMemset()
else if (Token::Match(tok, "memset ( & %var% , %num% , sizeof ( %var% ) )"))
{
unsigned int varid = tok->tokAt(3)->varId();
for (const Token *lookback = tok->previous(); lookback; lookback = lookback->previous())
{
if (Token::Match(lookback, "%type% %varid%", varid))
{
type = lookback->str();
break;
}
}
const Variable *var = symbolDatabase->getVariableFromVarId(varid);
if (var && var->typeStartToken() == var->typeEndToken())
type = var->typeStartToken()->str();
}
// No type defined => The tokens didn't match