convert CheckOther::checkSizeofForNumericParameter() to use the symbol database
This commit is contained in:
parent
741eabba16
commit
cd2c0fd9c8
|
@ -230,6 +230,8 @@ void CheckOther::checkSizeofForNumericParameter()
|
||||||
|
|
||||||
void CheckOther::checkSizeofForArrayParameter()
|
void CheckOther::checkSizeofForArrayParameter()
|
||||||
{
|
{
|
||||||
|
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
|
|
||||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
if (Token::Match(tok, "sizeof ( %var% )") || Token::Match(tok, "sizeof %var%"))
|
if (Token::Match(tok, "sizeof ( %var% )") || Token::Match(tok, "sizeof %var%"))
|
||||||
|
@ -241,9 +243,10 @@ void CheckOther::checkSizeofForArrayParameter()
|
||||||
}
|
}
|
||||||
if (tok->tokAt(tokIdx)->varId() > 0)
|
if (tok->tokAt(tokIdx)->varId() > 0)
|
||||||
{
|
{
|
||||||
const Token *declTok = Token::findmatch(_tokenizer->tokens(), "%varid%", tok->tokAt(tokIdx)->varId());
|
const Variable *var = symbolDatabase->getVariableFromVarId(tok->tokAt(tokIdx)->varId());
|
||||||
if (declTok)
|
if (var)
|
||||||
{
|
{
|
||||||
|
const Token *declTok = var->nameToken();
|
||||||
if (Token::simpleMatch(declTok->next(), "["))
|
if (Token::simpleMatch(declTok->next(), "["))
|
||||||
{
|
{
|
||||||
declTok = declTok->next()->link();
|
declTok = declTok->next()->link();
|
||||||
|
|
Loading…
Reference in New Issue