CheckStl: Use ValueType
This commit is contained in:
parent
adab48a0e1
commit
2f38d3d80e
|
@ -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"))
|
if (!var || !var->isLocal() || !Token::Match(var->typeEndToken(), "iterator|const_iterator|reverse_iterator|const_reverse_iterator|auto"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (var->typeEndToken()->str() == "auto") {
|
if (var->typeEndToken()->str() == "auto")
|
||||||
if (Token::Match(var->typeEndToken(), "auto %name% ; %name% = %var% . %name% ( )")) {
|
return (var->nameToken()->valueType() && var->nameToken()->valueType()->type == ValueType::Type::ITERATOR);
|
||||||
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->type()) { // If it is defined, ensure that it is defined like an iterator
|
if (var->type()) { // If it is defined, ensure that it is defined like an iterator
|
||||||
// look for operator* and operator++
|
// look for operator* and operator++
|
||||||
|
|
Loading…
Reference in New Issue