diff --git a/.selfcheck_suppressions b/.selfcheck_suppressions index 82257c229..7e1de66f2 100644 --- a/.selfcheck_suppressions +++ b/.selfcheck_suppressions @@ -2,7 +2,6 @@ shadowFunction bitwiseOnBoolean # temporary suppressions - fix the warnings! -useStlAlgorithm simplifyUsing:lib/valueptr.h varid0:gui/projectfile.cpp diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index d78ce0272..82ba2c279 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -243,10 +243,11 @@ int CppCheckExecutor::check_wrapper(CppCheck& cppcheck) } bool CppCheckExecutor::reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::map &files, ErrorLogger& errorLogger) { - for (const Suppressions::Suppression& suppression: settings.nomsg.getSuppressions()) { - if (suppression.errorId == "unmatchedSuppression" && suppression.fileName.empty() && suppression.lineNumber == Suppressions::Suppression::NO_LINE) - return false; - } + const auto& suppressions = settings.nomsg.getSuppressions(); + if (std::any_of(suppressions.begin(), suppressions.end(), [](const Suppressions::Suppression& s) { + return s.errorId == "unmatchedSuppression" && s.fileName.empty() && s.lineNumber == Suppressions::Suppression::NO_LINE; + })) + return false; bool err = false; if (settings.jointSuppressionReport) { diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 96e85e9d8..39f18b904 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -4633,10 +4633,12 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con const Variable *Scope::getVariable(const std::string &varname) const { - for (const Variable& var: varlist) { - if (var.name() == varname) - return &var; - } + auto it = std::find_if(varlist.begin(), varlist.end(), [&varname](const Variable& var) { + return var.name() == varname; + }); + if (it != varlist.end()) + return &*it; + if (definedType) { for (const Type::BaseInfo& baseInfo: definedType->derivedFrom) { if (baseInfo.type && baseInfo.type->classScope) {