assume all std::*::size() and std::*::empty() are const in CheckClass::checkConstFunc()
This commit is contained in:
parent
addcec704f
commit
e687ee9a9a
|
@ -1632,21 +1632,12 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Token *tok)
|
|||
}
|
||||
else if (Token::Match(tok1, "%var% . size|empty ( )") && tok1->varId())
|
||||
{
|
||||
// STL container size() is const
|
||||
static const char STL_CONTAINER_LIST[] = "bitset|deque|list|map|multimap|multiset|priority_queue|queue|set|stack|hash_map|hash_multimap|hash_set|string|vector";
|
||||
// assume all std::*::size() and std::*::empty() are const
|
||||
const Variable *var = symbolDatabase->getVariableFromVarId(tok1->varId());
|
||||
|
||||
if (var)
|
||||
{
|
||||
const Token *tok2 = var->typeStartToken();
|
||||
// skip namespace if present
|
||||
if (Token::simpleMatch(tok2, "std ::"))
|
||||
tok2 = tok2->tokAt(2);
|
||||
// check for STL container
|
||||
if (Token::Match(tok2, STL_CONTAINER_LIST))
|
||||
if (var && Token::simpleMatch(var->typeStartToken(), "std ::"))
|
||||
tok1 = tok1->tokAt(4);
|
||||
}
|
||||
}
|
||||
|
||||
// delete..
|
||||
else if (tok1->str() == "delete")
|
||||
|
|
Loading…
Reference in New Issue