From 9a70ec87a8069d489e254b20d9d5433f48f80662 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sun, 14 Aug 2011 10:46:35 -0400 Subject: [PATCH] convert CheckStl::if_find() to use the symbol database --- lib/checkstl.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 20d94217d..81c8b3812 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -746,6 +746,9 @@ void CheckStl::if_find() { if (!_settings->isEnabled("style")) return; + + const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); + for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { if (Token::Match(tok, "if ( !| %var% . find ( %any% ) )")) @@ -756,10 +759,11 @@ void CheckStl::if_find() tok = tok->next(); 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? - const Token * decl = Token::findmatch(_tokenizer->tokens(), "%varid%", varid); + const Token * decl = var->nameToken(); while (decl && !Token::Match(decl, "[;{}(,]")) decl = decl->previous();