convert CheckStl::if_find() to use the symbol database
This commit is contained in:
parent
ad45ba718c
commit
9a70ec87a8
|
@ -746,6 +746,9 @@ void CheckStl::if_find()
|
||||||
{
|
{
|
||||||
if (!_settings->isEnabled("style"))
|
if (!_settings->isEnabled("style"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
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, "if ( !| %var% . find ( %any% ) )"))
|
if (Token::Match(tok, "if ( !| %var% . find ( %any% ) )"))
|
||||||
|
@ -756,10 +759,11 @@ void CheckStl::if_find()
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
|
||||||
const unsigned int varid = tok->varId();
|
const unsigned int varid = tok->varId();
|
||||||
if (varid > 0)
|
const Variable *var = symbolDatabase->getVariableFromVarId(varid);
|
||||||
|
if (var)
|
||||||
{
|
{
|
||||||
// Is the variable a std::string or STL container?
|
// Is the variable a std::string or STL container?
|
||||||
const Token * decl = Token::findmatch(_tokenizer->tokens(), "%varid%", varid);
|
const Token * decl = var->nameToken();
|
||||||
while (decl && !Token::Match(decl, "[;{}(,]"))
|
while (decl && !Token::Match(decl, "[;{}(,]"))
|
||||||
decl = decl->previous();
|
decl = decl->previous();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue