diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 20bb09f08..6cc824e20 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -172,6 +172,8 @@ int CppCheckExecutor::check(int argc, const char* const argv[]) if (!_settings._errorsOnly) reportStatus(c + 1, _filenames.size(), processedsize, totalfilesize); } + + cppCheck.checkFunctionUsage(); } else if (!ThreadExecutor::isEnabled()) { diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index dbb44eac9..53654bf0c 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -191,21 +191,26 @@ unsigned int CppCheck::processFile() reportUnmatchedSuppressions(_settings.nomsg.getUnmatchedLocalSuppressions(_filename)); + _errorList.clear(); + return exitcode; +} + +void CppCheck::checkFunctionUsage() +{ // This generates false positives - especially for libraries - const bool verbose_orig = _settings._verbose; - _settings._verbose = false; if (_settings.isEnabled("unusedFunction") && _settings._jobs == 1) { + const bool verbose_orig = _settings._verbose; + _settings._verbose = false; + _errout.str(""); if (_settings._errorsOnly == false) _errorLogger.reportOut("Checking usage of global functions.."); _checkUnusedFunctions.check(this); - } - _settings._verbose = verbose_orig; - _errorList.clear(); - return exitcode; + _settings._verbose = verbose_orig; + } } void CppCheck::analyseFile(std::istream &fin, const std::string &filename) diff --git a/lib/cppcheck.h b/lib/cppcheck.h index 77b029c13..e1800e544 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -79,6 +79,12 @@ public: */ unsigned int check(const std::string &path, const std::string &content); + /** + * @brief Check function usage. + * @note Call this after all files has been checked + */ + void checkFunctionUsage(); + /** * @brief Adjust the settings before doing the check. E.g. show only * actual bugs or also coding style issues.