Refactoring: Use range for loop
This commit is contained in:
parent
2c49732eb8
commit
e552737028
|
@ -345,9 +345,7 @@ void CheckStl::mismatchingContainers()
|
||||||
{
|
{
|
||||||
// Check if different containers are used in various calls of standard functions
|
// Check if different containers are used in various calls of standard functions
|
||||||
const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
|
const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
|
||||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
for (const Scope * scope : symbolDatabase->functionScopes) {
|
||||||
for (std::size_t ii = 0; ii < functions; ++ii) {
|
|
||||||
const Scope * scope = symbolDatabase->functionScopes[ii];
|
|
||||||
for (const Token* tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
|
for (const Token* tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
|
||||||
if (!Token::Match(tok, "%name% ( !!)"))
|
if (!Token::Match(tok, "%name% ( !!)"))
|
||||||
continue;
|
continue;
|
||||||
|
@ -404,15 +402,15 @@ void CheckStl::stlOutOfBounds()
|
||||||
const SymbolDatabase* const symbolDatabase = mTokenizer->getSymbolDatabase();
|
const SymbolDatabase* const symbolDatabase = mTokenizer->getSymbolDatabase();
|
||||||
|
|
||||||
// Scan through all scopes..
|
// Scan through all scopes..
|
||||||
for (std::list<Scope>::const_iterator i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i) {
|
for (const Scope &scope : symbolDatabase->scopeList) {
|
||||||
const Token* tok = i->classDef;
|
const Token* tok = scope.classDef;
|
||||||
// only interested in conditions
|
// only interested in conditions
|
||||||
if ((i->type != Scope::eFor && i->type != Scope::eWhile && i->type != Scope::eIf && i->type != Scope::eDo) || !tok)
|
if ((scope.type != Scope::eFor && scope.type != Scope::eWhile && scope.type != Scope::eIf && scope.type != Scope::eDo) || !tok)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (i->type == Scope::eFor)
|
if (scope.type == Scope::eFor)
|
||||||
tok = Token::findsimplematch(tok->tokAt(2), ";");
|
tok = Token::findsimplematch(tok->tokAt(2), ";");
|
||||||
else if (i->type == Scope::eDo) {
|
else if (scope.type == Scope::eDo) {
|
||||||
tok = tok->linkAt(1)->tokAt(2);
|
tok = tok->linkAt(1)->tokAt(2);
|
||||||
} else
|
} else
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
@ -442,7 +440,7 @@ void CheckStl::stlOutOfBounds()
|
||||||
// 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->bodyStart; tok3 && tok3 != i->bodyEnd; tok3 = tok3->next()) {
|
for (const Token *tok3 = scope.bodyStart; tok3 && tok3 != scope.bodyEnd; 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% ( )")) {
|
||||||
|
|
Loading…
Reference in New Issue