convert CheckOther::checkCharVariable() to use symbol database

This commit is contained in:
Robert Reif 2011-08-14 10:39:45 -04:00
parent cd2c0fd9c8
commit ad45ba718c
1 changed files with 6 additions and 2 deletions

View File

@ -2887,6 +2887,8 @@ void CheckOther::checkCharVariable()
if (!_settings->isEnabled("style"))
return;
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
{
// Declaring the variable..
@ -2948,7 +2950,8 @@ void CheckOther::checkCharVariable()
}
// is the result stored in a short|int|long?
if (!Token::findmatch(_tokenizer->tokens(), "short|int|long %varid%", tok2->next()->varId()))
const Variable *var = symbolDatabase->getVariableFromVarId(tok2->next()->varId());
if (!(var && Token::Match(var->typeEndToken(), "short|int|long")))
continue;
// This is an error..
@ -2963,7 +2966,8 @@ void CheckOther::checkCharVariable()
continue;
// is the result stored in a short|int|long?
if (!Token::findmatch(_tokenizer->tokens(), "short|int|long %varid%", tok2->next()->varId()))
const Variable *var = symbolDatabase->getVariableFromVarId(tok2->next()->varId());
if (!(var && Token::Match(var->typeEndToken(), "short|int|long")))
continue;
// This is an error..