assume all std::*::size() and std::*::empty() are const in CheckClass::checkConstFunc()
This commit is contained in:
parent
addcec704f
commit
e687ee9a9a
|
@ -1632,20 +1632,11 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Token *tok)
|
||||||
}
|
}
|
||||||
else if (Token::Match(tok1, "%var% . size|empty ( )") && tok1->varId())
|
else if (Token::Match(tok1, "%var% . size|empty ( )") && tok1->varId())
|
||||||
{
|
{
|
||||||
// STL container size() is const
|
// assume all std::*::size() and std::*::empty() are 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";
|
|
||||||
const Variable *var = symbolDatabase->getVariableFromVarId(tok1->varId());
|
const Variable *var = symbolDatabase->getVariableFromVarId(tok1->varId());
|
||||||
|
|
||||||
if (var)
|
if (var && Token::simpleMatch(var->typeStartToken(), "std ::"))
|
||||||
{
|
tok1 = tok1->tokAt(4);
|
||||||
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))
|
|
||||||
tok1 = tok1->tokAt(4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete..
|
// delete..
|
||||||
|
|
Loading…
Reference in New Issue