unused functions: Created command line parameter --unused-functions
This commit is contained in:
parent
0ca38cc9fe
commit
dd9cd9ce82
|
@ -99,6 +99,10 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
||||||
else if (strcmp(argv[i], "--xml-results") == 0)
|
else if (strcmp(argv[i], "--xml-results") == 0)
|
||||||
_settings._xmlResults = true;
|
_settings._xmlResults = true;
|
||||||
|
|
||||||
|
// Check if there are unused functions
|
||||||
|
else if (strcmp(argv[i], "--unused-functions") == 0)
|
||||||
|
_settings._unusedFunctions = true;
|
||||||
|
|
||||||
// Print help
|
// Print help
|
||||||
else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
|
else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
|
||||||
{
|
{
|
||||||
|
@ -164,21 +168,25 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
||||||
"\n"
|
"\n"
|
||||||
"Syntax:\n"
|
"Syntax:\n"
|
||||||
" cppcheck [--all] [--force] [--help] [-Idir] [--quiet] [--style]\n"
|
" cppcheck [--all] [--force] [--help] [-Idir] [--quiet] [--style]\n"
|
||||||
" [--verbose] [file or path1] [file or path]\n"
|
" [--unused-functions] [--verbose] [--xml-results]\n"
|
||||||
|
" [file or path1] [file or path]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"If path is given instead of filename, *.cpp, *.cxx, *.cc, *.c++ and *.c files\n"
|
"If path is given instead of filename, *.cpp, *.cxx, *.cc, *.c++ and *.c files\n"
|
||||||
"are checked recursively from given directory.\n\n"
|
"are checked recursively from given directory.\n\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -a, --all Make the checking more sensitive. More bugs are detected,\n"
|
" -a, --all Make the checking more sensitive. More bugs are\n"
|
||||||
" but there are also more false positives\n"
|
" detected, but there are also more false positives\n"
|
||||||
" -f, --force Force checking on files that have \"too many\" configurations\n"
|
" -f, --force Force checking on files that have \"too many\"\n"
|
||||||
|
" configurations\n"
|
||||||
" -h, --help Print this help\n"
|
" -h, --help Print this help\n"
|
||||||
" -I <dir> Give include path. Give several -I parameters to give\n"
|
" -I <dir> Give include path. Give several -I parameters to give\n"
|
||||||
" several paths. First given path is checked first. If paths\n"
|
" several paths. First given path is checked first. If\n"
|
||||||
" are relative to source files, this is not needed.\n"
|
" paths are relative to source files, this is not needed\n"
|
||||||
" -q, --quiet Only print error messages\n"
|
" -q, --quiet Only print error messages\n"
|
||||||
" -s, --style Check coding style\n"
|
" -s, --style Check coding style\n"
|
||||||
|
" --unused-functions Check if there are unused functions\n"
|
||||||
" -v, --verbose More detailed error reports\n"
|
" -v, --verbose More detailed error reports\n"
|
||||||
|
" --xml-results Write results in results.xml\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Example usage:\n"
|
"Example usage:\n"
|
||||||
" # Recursively check the current folder. Print the progress on the screen and\n"
|
" # Recursively check the current folder. Print the progress on the screen and\n"
|
||||||
|
@ -267,7 +275,7 @@ unsigned int CppCheck::check()
|
||||||
|
|
||||||
// This generates false positives - especially for libraries
|
// This generates false positives - especially for libraries
|
||||||
_settings._verbose = false;
|
_settings._verbose = false;
|
||||||
if (ErrorMessage::unusedFunction(_settings))
|
if (_settings._unusedFunctions)
|
||||||
{
|
{
|
||||||
_errout.str("");
|
_errout.str("");
|
||||||
if (_settings._errorsOnly == false)
|
if (_settings._errorsOnly == false)
|
||||||
|
@ -351,7 +359,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
||||||
_tokenizer.simplifyTokenList();
|
_tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
|
|
||||||
if (ErrorMessage::unusedFunction(_settings))
|
if (_settings._unusedFunctions)
|
||||||
_checkFunctionUsage.parseTokens(_tokenizer);
|
_checkFunctionUsage.parseTokens(_tokenizer);
|
||||||
|
|
||||||
// Class for detecting buffer overruns and related problems
|
// Class for detecting buffer overruns and related problems
|
||||||
|
|
|
@ -28,6 +28,7 @@ Settings::Settings()
|
||||||
_verbose = false;
|
_verbose = false;
|
||||||
_force = false;
|
_force = false;
|
||||||
_xmlResults = false;
|
_xmlResults = false;
|
||||||
|
_unusedFunctions = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::~Settings()
|
Settings::~Settings()
|
||||||
|
|
|
@ -42,6 +42,9 @@ public:
|
||||||
|
|
||||||
/** write results in xml file results.xml */
|
/** write results in xml file results.xml */
|
||||||
bool _xmlResults;
|
bool _xmlResults;
|
||||||
|
|
||||||
|
/** Checking if there are unused functions */
|
||||||
|
bool _unusedFunctions;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGS_H
|
#endif // SETTINGS_H
|
||||||
|
|
Loading…
Reference in New Issue