Fix a few useStlAlgorithm warnings

This commit is contained in:
Daniel Marjamäki 2019-05-08 20:23:32 +02:00
parent df03514c0b
commit 66b2b31eb0
2 changed files with 11 additions and 16 deletions

View File

@ -537,8 +537,7 @@ std::list<ErrorLogger::ErrorMessage::FileLocation> CTU::FileInfo::getErrorPath(I
if (functionCall) {
if (functionCallPtr)
*functionCallPtr = functionCall;
for (const ErrorLogger::ErrorMessage::FileLocation &loc : functionCall->callValuePath)
locationList.push_back(loc);
std::copy(functionCall->callValuePath.cbegin(), functionCall->callValuePath.cend(), std::back_inserter(locationList));
}
ErrorLogger::ErrorMessage::FileLocation fileLoc;

View File

@ -296,11 +296,10 @@ static bool isUndefined(const std::string &cfg, const std::set<std::string> &und
static bool getConfigsElseIsFalse(const std::vector<std::string> &configs_if, const std::string &userDefines)
{
for (const std::string &cfg : configs_if) {
if (hasDefine(userDefines, cfg))
return true;
}
return false;
return std::any_of(configs_if.cbegin(), configs_if.cend(),
[=](const std::string &cfg) {
return hasDefine(userDefines, cfg);
});
}
static const simplecpp::Token *gotoEndIf(const simplecpp::Token *cmdtok)
@ -500,8 +499,7 @@ void Preprocessor::preprocess(std::istream &srcCodeStream, std::string &processe
const simplecpp::TokenList tokens1(srcCodeStream, files, filename, &outputList);
const std::set<std::string> configs = getConfigs(tokens1);
for (const std::string &cfg : configs)
resultConfigurations.push_back(cfg);
std::copy(configs.cbegin(), configs.cend(), std::back_inserter(resultConfigurations));
processedFile = tokens1.stringify();
}
@ -788,13 +786,11 @@ bool Preprocessor::validateCfg(const std::string &cfg, const std::list<simplecpp
continue;
if (mu.macroName != macroName)
continue;
bool directiveLocation = false;
for (const Directive &dir : mDirectives) {
if (mu.useLocation.file() == dir.file && mu.useLocation.line == dir.linenr) {
directiveLocation = true;
break;
}
}
bool directiveLocation = std::any_of(mDirectives.cbegin(), mDirectives.cend(),
[=](const Directive &dir) {
return mu.useLocation.file() == dir.file && mu.useLocation.line == dir.linenr;
});
if (!directiveLocation) {
if (mSettings.isEnabled(Settings::INFORMATION))
validateCfgError(mu.useLocation.file(), mu.useLocation.line, cfg, macroName);