|
Cppcheck
|
Various small checks. More...
#include <checkunusedvar.h>
Public Member Functions | |
| CheckUnusedVar () | |
| This constructor is used when registering the CheckClass. | |
| CheckUnusedVar (const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) | |
| This constructor is used when running checks. | |
| void | runChecks (const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) |
| Run checks against the normal token list. | |
| void | runSimplifiedChecks (const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) |
| Run checks against the simplified token list. | |
| void | checkFunctionVariableUsage_iterateScopes (const Scope *const scope, Variables &variables, bool insideLoop) |
| Check for unused function variables | |
| void | checkVariableUsage (const Scope *const scope, const Token *start, Variables &variables) |
| void | checkFunctionVariableUsage () |
| void | checkStructMemberUsage () |
| Check that all struct members are used | |
Private Member Functions | |
| void | unusedStructMemberError (const Token *tok, const std::string &structname, const std::string &varname) |
| void | unusedVariableError (const Token *tok, const std::string &varname) |
| void | allocatedButUnusedVariableError (const Token *tok, const std::string &varname) |
| void | unreadVariableError (const Token *tok, const std::string &varname) |
| void | unassignedVariableError (const Token *tok, const std::string &varname) |
| void | getErrorMessages (ErrorLogger *errorLogger, const Settings *settings) const |
| get error messages | |
| std::string | classInfo () const |
| get information about this class, used to generate documentation | |
Static Private Member Functions | |
| static std::string | myName () |
Various small checks.
Definition at line 39 of file checkunusedvar.h.
| CheckUnusedVar::CheckUnusedVar | ( | ) | [inline] |
This constructor is used when registering the CheckClass.
Definition at line 42 of file checkunusedvar.h.
| CheckUnusedVar::CheckUnusedVar | ( | const Tokenizer * | tokenizer, |
| const Settings * | settings, | ||
| ErrorLogger * | errorLogger | ||
| ) | [inline] |
This constructor is used when running checks.
Definition at line 46 of file checkunusedvar.h.
| void CheckUnusedVar::allocatedButUnusedVariableError | ( | const Token * | tok, |
| const std::string & | varname | ||
| ) | [private] |
Definition at line 1130 of file checkunusedvar.cpp.
References Check::reportError(), and Severity::style.
Referenced by checkFunctionVariableUsage(), and getErrorMessages().
Definition at line 1064 of file checkunusedvar.cpp.
References Variables::VariableUsage::_allocateMemory, Variables::VariableUsage::_lastAccess, Variables::VariableUsage::_modified, Variables::VariableUsage::_read, Check::_settings, Check::_tokenizer, Variables::VariableUsage::_type, Variables::VariableUsage::_var, Variables::VariableUsage::_write, allocatedButUnusedVariableError(), checkFunctionVariableUsage_iterateScopes(), SymbolDatabase::functionScopes, Tokenizer::getSymbolDatabase(), SymbolDatabase::getVariableFromVarId(), Settings::isEnabled(), Token::isUnused(), Variable::name(), Variable::nameToken(), Variables::pointerArray, Variables::pointerPointer, Variables::referenceArray, Token::simpleMatch(), Variable::typeStartToken(), unassignedVariableError(), unreadVariableError(), Variables::VariableUsage::unused(), unusedVariableError(), and Variables::varUsage().
Referenced by runChecks().
| void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes | ( | const Scope *const | scope, |
| Variables & | variables, | ||
| bool | insideLoop | ||
| ) |
Check for unused function variables
Definition at line 676 of file checkunusedvar.cpp.
References Variables::VariableUsage::_allocateMemory, Check::_tokenizer, Variables::VariableUsage::_type, Variables::addVar(), Variables::allocateMemory(), Variables::array, Scope::classDef, Scope::classEnd, Variables::clear(), doAssignment(), Token::eIncDecOp, Variables::erase(), Variables::find(), Tokenizer::isC(), Tokenizer::isCPP(), Scope::isExecutable(), isPartOfClassStructUnion(), isRecordTypeWithoutSideEffects(), Variable::isReference(), Token::isStandardType(), Token::link(), Token::linkAt(), Token::Match(), Variables::modified(), Variable::nameToken(), Scope::nestedList, Variables::newScope(), Token::next(), Variables::none, Variables::pointer, Variables::pointerArray, Variables::pointerPointer, Variables::read(), Variables::readAll(), Variables::reference, Variables::referenceArray, Token::simpleMatch(), skipBrackets(), skipBracketsAndMembers(), Variables::standard, Token::str(), Token::strAt(), Token::tokAt(), Variable::type(), Variable::typeEndToken(), Variables::use(), Token::variable(), Token::varId(), Scope::varlist, Variables::write(), Variables::writeAliases(), and Variables::writeAll().
Referenced by checkFunctionVariableUsage().
Check that all struct members are used
Definition at line 1148 of file checkunusedvar.cpp.
References Check::_settings, Check::_tokenizer, Token::findmatch(), Settings::isEnabled(), Variable::isExtern(), Variable::isGlobal(), Variable::isStatic(), Token::Match(), Token::next(), Token::simpleMatch(), Token::strAt(), Token::tokAt(), Tokenizer::tokens(), and unusedStructMemberError().
Referenced by runChecks().
| void CheckUnusedVar::checkVariableUsage | ( | const Scope *const | scope, |
| const Token * | start, | ||
| Variables & | variables | ||
| ) |
| std::string CheckUnusedVar::classInfo | ( | ) | const [inline, private, virtual] |
get information about this class, used to generate documentation
Implements Check.
Definition at line 97 of file checkunusedvar.h.
| void CheckUnusedVar::getErrorMessages | ( | ErrorLogger * | errorLogger, |
| const Settings * | settings | ||
| ) | const [inline, private, virtual] |
get error messages
Implements Check.
Definition at line 82 of file checkunusedvar.h.
References allocatedButUnusedVariableError(), unassignedVariableError(), unreadVariableError(), unusedStructMemberError(), and unusedVariableError().
| static std::string CheckUnusedVar::myName | ( | ) | [inline, static, private] |
Definition at line 93 of file checkunusedvar.h.
| void CheckUnusedVar::runChecks | ( | const Tokenizer * | tokenizer, |
| const Settings * | settings, | ||
| ErrorLogger * | errorLogger | ||
| ) | [inline, virtual] |
Run checks against the normal token list.
Reimplemented from Check.
Definition at line 51 of file checkunusedvar.h.
References checkFunctionVariableUsage(), and checkStructMemberUsage().
| void CheckUnusedVar::runSimplifiedChecks | ( | const Tokenizer * | tokenizer, |
| const Settings * | settings, | ||
| ErrorLogger * | errorLogger | ||
| ) | [inline, virtual] |
Run checks against the simplified token list.
Implements Check.
Definition at line 60 of file checkunusedvar.h.
| void CheckUnusedVar::unassignedVariableError | ( | const Token * | tok, |
| const std::string & | varname | ||
| ) | [private] |
Definition at line 1140 of file checkunusedvar.cpp.
References Check::reportError(), and Severity::style.
Referenced by checkFunctionVariableUsage(), and getErrorMessages().
| void CheckUnusedVar::unreadVariableError | ( | const Token * | tok, |
| const std::string & | varname | ||
| ) | [private] |
Definition at line 1135 of file checkunusedvar.cpp.
References Check::reportError(), and Severity::style.
Referenced by checkFunctionVariableUsage(), and getErrorMessages().
| void CheckUnusedVar::unusedStructMemberError | ( | const Token * | tok, |
| const std::string & | structname, | ||
| const std::string & | varname | ||
| ) | [private] |
Definition at line 1253 of file checkunusedvar.cpp.
References Check::reportError(), and Severity::style.
Referenced by checkStructMemberUsage(), and getErrorMessages().
| void CheckUnusedVar::unusedVariableError | ( | const Token * | tok, |
| const std::string & | varname | ||
| ) | [private] |
Definition at line 1125 of file checkunusedvar.cpp.
References Check::reportError(), and Severity::style.
Referenced by checkFunctionVariableUsage(), and getErrorMessages().
1.7.6.1