Cppcheck
|
Check for functions never called. More...
#include <checkunusedfunctions.h>
Classes | |
class | FunctionDecl |
struct | FunctionUsage |
Public Member Functions | |
CheckUnusedFunctions ()=default | |
void | parseTokens (const Tokenizer &tokenizer, const Settings &settings) |
std::string | analyzerInfo () const |
bool | check (const Settings &settings, ErrorLogger &errorLogger) const |
void | updateFunctionData (const CheckUnusedFunctions &check) |
Static Public Member Functions | |
static void | analyseWholeProgram (const Settings &settings, ErrorLogger &errorLogger, const std::string &buildDir) |
static void | getErrorMessages (ErrorLogger &errorLogger) |
Static Private Member Functions | |
static void | unusedFunctionError (ErrorLogger &errorLogger, const std::string &filename, unsigned int fileIndex, unsigned int lineNumber, const std::string &funcname) |
Private Attributes | |
std::unordered_map< std::string, FunctionUsage > | mFunctions |
std::list< FunctionDecl > | mFunctionDecl |
std::set< std::string > | mFunctionCalls |
Friends | |
class | TestSuppressions |
class | TestSingleExecutorBase |
class | TestProcessExecutorBase |
class | TestThreadExecutorBase |
class | TestUnusedFunctions |
Check for functions never called.
Definition at line 40 of file checkunusedfunctions.h.
|
default |
|
static |
Definition at line 393 of file checkunusedfunctions.cpp.
References error, Library::isentrypoint(), isOperatorFunction(), Settings::library, stripTemplateParameters(), and unusedFunctionError().
Referenced by CppCheck::analyseWholeProgram().
std::string CheckUnusedFunctions::analyzerInfo | ( | ) | const |
Definition at line 370 of file checkunusedfunctions.cpp.
References mFunctionCalls, mFunctionDecl, and ErrorLogger::toxml().
Referenced by CppCheck::checkNormalTokens().
bool CheckUnusedFunctions::check | ( | const Settings & | settings, |
ErrorLogger & | errorLogger | ||
) | const |
Definition at line 316 of file checkunusedfunctions.cpp.
References CheckUnusedFunctions::FunctionUsage::fileIndex, CheckUnusedFunctions::FunctionUsage::filename, Library::isentrypoint(), isOperatorFunction(), Settings::library, CheckUnusedFunctions::FunctionUsage::lineNumber, logChecker, mFunctions, unusedFunctionError(), CheckUnusedFunctions::FunctionUsage::usedOtherFile, and CheckUnusedFunctions::FunctionUsage::usedSameFile.
Referenced by updateFunctionData().
|
inlinestatic |
Definition at line 59 of file checkunusedfunctions.h.
References emptyString.
Referenced by CppCheck::getErrorMessages().
Definition at line 62 of file checkunusedfunctions.cpp.
References Library::blockend(), Library::blockstart(), Library::blockstartoffset(), Function::eFunction, TokenList::file(), CheckUnusedFunctions::FunctionUsage::fileIndex, Token::fileIndex(), CheckUnusedFunctions::FunctionUsage::filename, findLambdaEndToken(), Scope::function, SymbolDatabase::functionScopes, TokenList::getFiles(), Tokenizer::getSymbolDatabase(), Function::isAttributeConstructor(), Function::isAttributeDestructor(), Library::isexecutableblock(), Library::isexportedprefix(), Library::isexportedsuffix(), Library::isexporter(), Function::isExtern(), Library::isimporter(), Token::isKeyword(), Library::iskeyword(), Function::isOperator(), Library::isreflection(), Token::isStandardType(), Settings::library, Token::linenr(), CheckUnusedFunctions::FunctionUsage::lineNumber, Token::link(), Token::linkAt(), Tokenizer::list, Library::markupFile(), Token::Match(), mFunctionCalls, mFunctionDecl, mFunctions, Function::name(), Token::next(), Token::previous(), Library::reflectionArgument(), Token::scope(), Token::simpleMatch(), Token::str(), stripTemplateParameters(), Token::tokAt(), Function::token, Tokenizer::tokens(), Function::type, CheckUnusedFunctions::FunctionUsage::usedOtherFile, CheckUnusedFunctions::FunctionUsage::usedSameFile, and Token::varId().
Referenced by CppCheck::checkNormalTokens().
|
staticprivate |
Definition at line 352 of file checkunusedfunctions.cpp.
References CWE561, emptyString, normal, ErrorLogger::reportErr(), and style.
Referenced by analyseWholeProgram(), and check().
void CheckUnusedFunctions::updateFunctionData | ( | const CheckUnusedFunctions & | check | ) |
Definition at line 458 of file checkunusedfunctions.cpp.
References check(), CheckUnusedFunctions::FunctionUsage::fileIndex, CheckUnusedFunctions::FunctionUsage::filename, CheckUnusedFunctions::FunctionUsage::lineNumber, mFunctionCalls, mFunctionDecl, mFunctions, CheckUnusedFunctions::FunctionUsage::usedOtherFile, and CheckUnusedFunctions::FunctionUsage::usedSameFile.
|
friend |
Definition at line 43 of file checkunusedfunctions.h.
|
friend |
Definition at line 42 of file checkunusedfunctions.h.
|
friend |
Definition at line 41 of file checkunusedfunctions.h.
|
friend |
Definition at line 44 of file checkunusedfunctions.h.
|
friend |
Definition at line 45 of file checkunusedfunctions.h.
|
private |
Definition at line 90 of file checkunusedfunctions.h.
Referenced by analyzerInfo(), parseTokens(), and updateFunctionData().
|
private |
Definition at line 89 of file checkunusedfunctions.h.
Referenced by analyzerInfo(), parseTokens(), and updateFunctionData().
|
private |
Definition at line 81 of file checkunusedfunctions.h.
Referenced by check(), parseTokens(), and updateFunctionData().