Fixed #2941 (False positive: unused function (individual checking of files))
This commit is contained in:
parent
9a3f95613a
commit
c1138cf7f9
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue