CheckStl: Use ValueType

This commit is contained in:
Daniel Marjamäki 2017-07-26 20:19:36 +02:00
parent adab48a0e1
commit 2f38d3d80e
1 changed files with 2 additions and 16 deletions

View File

@ -91,22 +91,8 @@ bool CheckStl::isIterator(const Variable *var) const
if (!var || !var->isLocal() || !Token::Match(var->typeEndToken(), "iterator|const_iterator|reverse_iterator|const_reverse_iterator|auto"))
return false;
if (var->typeEndToken()->str() == "auto") {
if (Token::Match(var->typeEndToken(), "auto %name% ; %name% = %var% . %name% ( )")) {
const Token* containertok = var->typeEndToken()->tokAt(5);
if (!containertok->variable())
return false;
const Library::Container* container = _settings->library.detectContainer(containertok->variable()->typeStartToken());
if (!container)
return false;
Library::Container::Yield yield = container->getYield(containertok->strAt(2));
if (yield != Library::Container::END_ITERATOR && yield != Library::Container::START_ITERATOR && yield != Library::Container::ITERATOR)
return false;
} else
return false;
}
if (var->typeEndToken()->str() == "auto")
return (var->nameToken()->valueType() && var->nameToken()->valueType()->type == ValueType::Type::ITERATOR);
if (var->type()) { // If it is defined, ensure that it is defined like an iterator
// look for operator* and operator++