Refactoring; Use range for loops

This commit is contained in:
Daniel Marjamäki 2018-07-14 22:49:31 +02:00
parent 991300ac54
commit 60485df762
1 changed files with 14 additions and 14 deletions

View File

@ -1285,8 +1285,8 @@ void Tokenizer::simplifyTypedef()
tok2 = TokenList::copyTokens(tok2, typeStart->next(), typeEnd); tok2 = TokenList::copyTokens(tok2, typeStart->next(), typeEnd);
if (!pointers.empty()) { if (!pointers.empty()) {
for (std::list<std::string>::const_iterator iter = pointers.begin(); iter != pointers.end(); ++iter) { for (const std::string &p : pointers) {
tok2->insertToken(*iter); tok2->insertToken(p);
tok2 = tok2->next(); tok2 = tok2->next();
} }
} }
@ -2863,8 +2863,8 @@ namespace {
static std::string getScopeName(const std::list<ScopeInfo2> &scopeInfo) static std::string getScopeName(const std::list<ScopeInfo2> &scopeInfo)
{ {
std::string ret; std::string ret;
for (std::list<ScopeInfo2>::const_iterator it = scopeInfo.begin(); it != scopeInfo.end(); ++it) for (const ScopeInfo2 &si : scopeInfo)
ret += (ret.empty() ? "" : " :: ") + (it->name); ret += (ret.empty() ? "" : " :: ") + (si.name);
return ret; return ret;
} }
@ -2925,8 +2925,8 @@ static Token * matchMemberName(const Member &member, const std::list<ScopeInfo2>
return ret; return ret;
// Try to match member using the "using namespace ..." namespaces.. // Try to match member using the "using namespace ..." namespaces..
for (std::list<const Token *>::const_iterator ns = member.usingnamespaces.begin(); ns != member.usingnamespaces.end(); ++ns) { for (const Token *ns : member.usingnamespaces) {
ret = matchMemberName(member.scope, *ns, member.tok, scopeInfo); ret = matchMemberName(member.scope, ns, member.tok, scopeInfo);
if (ret) if (ret)
return ret; return ret;
} }
@ -3028,8 +3028,8 @@ void Tokenizer::setVarIdPass2()
} }
std::string classname; std::string classname;
for (std::list<const Token *>::const_iterator it = classnameTokens.begin(); it != classnameTokens.end(); ++it) for (const Token *it : classnameTokens)
classname += (classname.empty() ? "" : " :: ") + (*it)->str(); classname += (classname.empty() ? "" : " :: ") + it->str();
std::map<std::string, unsigned int> &thisClassVars = varsByClass[scopeName2 + classname]; std::map<std::string, unsigned int> &thisClassVars = varsByClass[scopeName2 + classname];
while (Token::Match(tokStart, ":|::|,|%name%")) { while (Token::Match(tokStart, ":|::|,|%name%")) {
@ -3049,8 +3049,8 @@ void Tokenizer::setVarIdPass2()
continue; continue;
// What member variables are there in this class? // What member variables are there in this class?
for (std::list<const Token *>::const_iterator it = classnameTokens.begin(); it != classnameTokens.end(); ++it) for (const Token *it : classnameTokens)
scopeInfo.emplace_back((*it)->str(), tokStart->link()); scopeInfo.emplace_back(it->str(), tokStart->link());
for (Token *tok2 = tokStart->next(); tok2 && tok2 != tokStart->link(); tok2 = tok2->next()) { for (Token *tok2 = tokStart->next(); tok2 && tok2 != tokStart->link(); tok2 = tok2->next()) {
// skip parentheses.. // skip parentheses..
@ -3073,8 +3073,8 @@ void Tokenizer::setVarIdPass2()
continue; continue;
// Member variables // Member variables
for (std::list<Member>::iterator var = allMemberVars.begin(); var != allMemberVars.end(); ++var) { for (const Member &var : allMemberVars) {
Token *tok2 = matchMemberVarName(*var, scopeInfo); Token *tok2 = matchMemberVarName(var, scopeInfo);
if (!tok2) if (!tok2)
continue; continue;
tok2->varId(thisClassVars[tok2->str()]); tok2->varId(thisClassVars[tok2->str()]);
@ -3084,8 +3084,8 @@ void Tokenizer::setVarIdPass2()
continue; continue;
// Set variable ids in member functions for this class.. // Set variable ids in member functions for this class..
for (std::list<Member>::const_iterator func = allMemberFunctions.begin(); func != allMemberFunctions.end(); ++func) { for (const Member &func : allMemberFunctions) {
Token *tok2 = matchMemberFunctionName(*func, scopeInfo); Token *tok2 = matchMemberFunctionName(func, scopeInfo);
if (!tok2) if (!tok2)
continue; continue;