From faea8e1c028907b278e10588fac96075497fe6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 15 Jul 2018 14:45:15 +0200 Subject: [PATCH] Refactoring: Use range for loops --- lib/templatesimplifier.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 09db58e17..7823eee49 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -456,8 +456,8 @@ namespace { static std::string getScopeName(const std::list &scopeInfo) { std::string ret; - for (std::list::const_iterator it = scopeInfo.begin(); it != scopeInfo.end(); ++it) - ret += (ret.empty() ? "" : " :: ") + (it->name); + for (const ScopeInfo2 &i : scopeInfo) + ret += (ret.empty() ? "" : " :: ") + i.name; return ret; } static std::string getFullName(const std::list &scopeInfo, const std::string &name) @@ -602,7 +602,7 @@ std::list TemplateSimplifier::getTemplateInsta void TemplateSimplifier::useDefaultArgumentValues(const std::list &templates, std::list * const templateInstantiations) { - for (std::list::const_iterator iter1 = templates.begin(); iter1 != templates.end(); ++iter1) { + for (const TokenAndName &template1 : templates) { // template parameters with default value has syntax such as: // x = y // this list will contain all the '=' tokens for such arguments @@ -620,7 +620,7 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list std::string classname; // Scan template declaration.. - for (Token *tok = iter1->token; tok; tok = tok->next()) { + for (Token *tok = template1.token; tok; tok = tok->next()) { if (Token::simpleMatch(tok, "template < >")) { // Ticket #5762: Skip specialization tokens tok = tok->tokAt(2); if (0 == templateParmDepth) @@ -665,8 +665,8 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list continue; // iterate through all template instantiations - for (std::list::const_iterator iter2 = templateInstantiations->begin(); iter2 != templateInstantiations->end(); ++iter2) { - Token *tok = iter2->token; + for (const TokenAndName &templateInst : *templateInstantiations) { + Token *tok = templateInst.token; if (!Token::simpleMatch(tok, (classname + " <").c_str())) continue; @@ -707,8 +707,7 @@ void TemplateSimplifier::useDefaultArgumentValues(const std::list } } - for (std::list::iterator it = eq.begin(); it != eq.end(); ++it) { - Token * const eqtok = *it; + for (Token * const eqtok : eq) { Token *tok2; int indentlevel = 0; for (tok2 = eqtok->next(); tok2; tok2 = tok2->next()) {