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 (functionCall) {
if (functionCallPtr) if (functionCallPtr)
*functionCallPtr = functionCall; *functionCallPtr = functionCall;
for (const ErrorLogger::ErrorMessage::FileLocation &loc : functionCall->callValuePath) std::copy(functionCall->callValuePath.cbegin(), functionCall->callValuePath.cend(), std::back_inserter(locationList));
locationList.push_back(loc);
} }
ErrorLogger::ErrorMessage::FileLocation fileLoc; 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) static bool getConfigsElseIsFalse(const std::vector<std::string> &configs_if, const std::string &userDefines)
{ {
for (const std::string &cfg : configs_if) { return std::any_of(configs_if.cbegin(), configs_if.cend(),
if (hasDefine(userDefines, cfg)) [=](const std::string &cfg) {
return true; return hasDefine(userDefines, cfg);
} });
return false;
} }
static const simplecpp::Token *gotoEndIf(const simplecpp::Token *cmdtok) 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 simplecpp::TokenList tokens1(srcCodeStream, files, filename, &outputList);
const std::set<std::string> configs = getConfigs(tokens1); const std::set<std::string> configs = getConfigs(tokens1);
for (const std::string &cfg : configs) std::copy(configs.cbegin(), configs.cend(), std::back_inserter(resultConfigurations));
resultConfigurations.push_back(cfg);
processedFile = tokens1.stringify(); processedFile = tokens1.stringify();
} }
@ -788,13 +786,11 @@ bool Preprocessor::validateCfg(const std::string &cfg, const std::list<simplecpp
continue; continue;
if (mu.macroName != macroName) if (mu.macroName != macroName)
continue; continue;
bool directiveLocation = false; bool directiveLocation = std::any_of(mDirectives.cbegin(), mDirectives.cend(),
for (const Directive &dir : mDirectives) { [=](const Directive &dir) {
if (mu.useLocation.file() == dir.file && mu.useLocation.line == dir.linenr) { return mu.useLocation.file() == dir.file && mu.useLocation.line == dir.linenr;
directiveLocation = true; });
break;
}
}
if (!directiveLocation) { if (!directiveLocation) {
if (mSettings.isEnabled(Settings::INFORMATION)) if (mSettings.isEnabled(Settings::INFORMATION))
validateCfgError(mu.useLocation.file(), mu.useLocation.line, cfg, macroName); validateCfgError(mu.useLocation.file(), mu.useLocation.line, cfg, macroName);