Refactoring: Use continue in loop
This commit is contained in:
parent
2f38d3d80e
commit
2d4f64027a
|
@ -386,41 +386,40 @@ void CheckStl::stlOutOfBounds()
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
|
||||||
// check if the for loop condition is wrong
|
// check if the for loop condition is wrong
|
||||||
if (Token::Match(tok, "%var% <= %var% . %name% ( ) ;|)|%oror%")) {
|
if (!Token::Match(tok, "%var% <= %var% . %name% ( ) ;|)|%oror%"))
|
||||||
// Is it a vector?
|
continue;
|
||||||
const Variable *var = tok->tokAt(2)->variable();
|
// Is it a vector?
|
||||||
if (!var)
|
const Variable *var = tok->tokAt(2)->variable();
|
||||||
continue;
|
if (!var)
|
||||||
|
continue;
|
||||||
|
|
||||||
const Library::Container* container = _settings->library.detectContainer(var->typeStartToken());
|
const Library::Container* container = _settings->library.detectContainer(var->typeStartToken());
|
||||||
if (!container)
|
if (!container)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (container->getYield(tok->strAt(4)) != Library::Container::SIZE)
|
if (container->getYield(tok->strAt(4)) != Library::Container::SIZE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// variable id for loop variable.
|
// variable id for loop variable.
|
||||||
const unsigned int numId = tok->varId();
|
const unsigned int numId = tok->varId();
|
||||||
|
|
||||||
// variable id for the container variable
|
// variable id for the container variable
|
||||||
const unsigned int declarationId = var->declarationId();
|
const unsigned int declarationId = var->declarationId();
|
||||||
|
|
||||||
for (const Token *tok3 = i->classStart; tok3 && tok3 != i->classEnd; tok3 = tok3->next()) {
|
for (const Token *tok3 = i->classStart; tok3 && tok3 != i->classEnd; tok3 = tok3->next()) {
|
||||||
if (tok3->varId() == declarationId) {
|
if (tok3->varId() == declarationId) {
|
||||||
tok3 = tok3->next();
|
tok3 = tok3->next();
|
||||||
if (Token::Match(tok3, ". %name% ( )")) {
|
if (Token::Match(tok3, ". %name% ( )")) {
|
||||||
if (container->getYield(tok3->strAt(1)) == Library::Container::SIZE)
|
if (container->getYield(tok3->strAt(1)) == Library::Container::SIZE)
|
||||||
break;
|
break;
|
||||||
} else if (container->arrayLike_indexOp && Token::Match(tok3, "[ %varid% ]", numId))
|
} else if (container->arrayLike_indexOp && Token::Match(tok3, "[ %varid% ]", numId))
|
||||||
stlOutOfBoundsError(tok3, tok3->strAt(1), var->name(), false);
|
stlOutOfBoundsError(tok3, tok3->strAt(1), var->name(), false);
|
||||||
else if (Token::Match(tok3, ". %name% ( %varid% )", numId)) {
|
else if (Token::Match(tok3, ". %name% ( %varid% )", numId)) {
|
||||||
Library::Container::Yield yield = container->getYield(tok3->strAt(1));
|
Library::Container::Yield yield = container->getYield(tok3->strAt(1));
|
||||||
if (yield == Library::Container::AT_INDEX)
|
if (yield == Library::Container::AT_INDEX)
|
||||||
stlOutOfBoundsError(tok3, tok3->strAt(3), var->name(), true);
|
stlOutOfBoundsError(tok3, tok3->strAt(3), var->name(), true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue