Library: Use range-based for loops (#4200)
This commit is contained in:
parent
8945c151f5
commit
fc6c203b0e
|
@ -1131,8 +1131,8 @@ bool Library::isScopeNoReturn(const Token *end, std::string *unknownFunc) const
|
||||||
|
|
||||||
const Library::Container* Library::detectContainer(const Token* typeStart, bool iterator) const
|
const Library::Container* Library::detectContainer(const Token* typeStart, bool iterator) const
|
||||||
{
|
{
|
||||||
for (std::map<std::string, Container>::const_iterator i = containers.begin(); i != containers.end(); ++i) {
|
for (const auto &c : containers) {
|
||||||
const Container& container = i->second;
|
const Container& container = c.second;
|
||||||
if (container.startPattern.empty())
|
if (container.startPattern.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1208,13 +1208,13 @@ bool Library::matchArguments(const Token *ftok, const std::string &functionName)
|
||||||
return (callargs == 0);
|
return (callargs == 0);
|
||||||
int args = 0;
|
int args = 0;
|
||||||
int firstOptionalArg = -1;
|
int firstOptionalArg = -1;
|
||||||
for (std::map<int, ArgumentChecks>::const_iterator it2 = it->second.argumentChecks.cbegin(); it2 != it->second.argumentChecks.cend(); ++it2) {
|
for (const auto & argCheck : it->second.argumentChecks) {
|
||||||
if (it2->first > args)
|
if (argCheck.first > args)
|
||||||
args = it2->first;
|
args = argCheck.first;
|
||||||
if (it2->second.optional && (firstOptionalArg == -1 || firstOptionalArg > it2->first))
|
if (argCheck.second.optional && (firstOptionalArg == -1 || firstOptionalArg > argCheck.first))
|
||||||
firstOptionalArg = it2->first;
|
firstOptionalArg = argCheck.first;
|
||||||
|
|
||||||
if (it2->second.formatstr || it2->second.variadic)
|
if (argCheck.second.formatstr || argCheck.second.variadic)
|
||||||
return args <= callargs;
|
return args <= callargs;
|
||||||
}
|
}
|
||||||
return (firstOptionalArg < 0) ? args == callargs : (callargs >= firstOptionalArg-1 && callargs <= args);
|
return (firstOptionalArg < 0) ? args == callargs : (callargs >= firstOptionalArg-1 && callargs <= args);
|
||||||
|
@ -1287,9 +1287,9 @@ bool Library::formatstr_function(const Token* ftok) const
|
||||||
int Library::formatstr_argno(const Token* ftok) const
|
int Library::formatstr_argno(const Token* ftok) const
|
||||||
{
|
{
|
||||||
const std::map<int, Library::ArgumentChecks>& argumentChecksFunc = functions.at(getFunctionName(ftok)).argumentChecks;
|
const std::map<int, Library::ArgumentChecks>& argumentChecksFunc = functions.at(getFunctionName(ftok)).argumentChecks;
|
||||||
for (std::map<int, Library::ArgumentChecks>::const_iterator i = argumentChecksFunc.cbegin(); i != argumentChecksFunc.cend(); ++i) {
|
for (const auto & argCheckFunc : argumentChecksFunc) {
|
||||||
if (i->second.formatstr) {
|
if (argCheckFunc.second.formatstr) {
|
||||||
return i->first - 1;
|
return argCheckFunc.first - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1373,8 +1373,8 @@ bool Library::hasminsize(const Token *ftok) const
|
||||||
const std::unordered_map<std::string, Function>::const_iterator it1 = functions.find(getFunctionName(ftok));
|
const std::unordered_map<std::string, Function>::const_iterator it1 = functions.find(getFunctionName(ftok));
|
||||||
if (it1 == functions.cend())
|
if (it1 == functions.cend())
|
||||||
return false;
|
return false;
|
||||||
for (std::map<int, ArgumentChecks>::const_iterator it2 = it1->second.argumentChecks.cbegin(); it2 != it1->second.argumentChecks.cend(); ++it2) {
|
for (const auto & argCheck : it1->second.argumentChecks) {
|
||||||
if (!it2->second.minsizes.empty())
|
if (!argCheck.second.minsizes.empty())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue