20 #ifndef checkunusedvarH 
   21 #define checkunusedvarH 
   48     friend class TestUnusedVar;
 
   57         : 
Check(myName(), tokenizer, settings, errorLogger) {}
 
   69     void checkFunctionVariableUsage_iterateScopes(
const Scope* 
const scope, 
Variables& variables);
 
   70     void checkFunctionVariableUsage();
 
   73     void checkStructMemberUsage();
 
   75     bool isRecordTypeWithoutSideEffects(
const Type* type);
 
   76     bool isVariableWithoutSideEffects(
const Variable& var, 
const Type* type = 
nullptr);
 
   77     bool isEmptyType(
const Type* type);
 
   78     bool isFunctionWithoutSideEffects(
const Function& func, 
const Token* functionUsageToken,
 
   79                                       std::list<const Function*> checkedFuncs);
 
   82     void unusedStructMemberError(
const Token *tok, 
const std::string &structname, 
const std::string &varname, 
const std::string& prefix = 
"struct");
 
   83     void unusedVariableError(
const Token *tok, 
const std::string &varname);
 
   84     void allocatedButUnusedVariableError(
const Token *tok, 
const std::string &varname);
 
   85     void unreadVariableError(
const Token *tok, 
const std::string &varname, 
bool modified);
 
   86     void unassignedVariableError(
const Token *tok, 
const std::string &varname);
 
  102         return "UnusedVar checks\n" 
  105                "- unused variable\n" 
  106                "- allocated but unused variable\n" 
  107                "- unread variable\n" 
  108                "- unassigned variable\n" 
  109                "- unused struct member\n";
 
void unassignedVariableError(const Token *tok, const std::string &varname)
 
std::map< const Type *, bool > mIsEmptyTypeMap
 
std::string classInfo() const override
get information about this class, used to generate documentation
 
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override
Run checks against the normal token list.
 
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override
get error messages
 
void allocatedButUnusedVariableError(const Token *tok, const std::string &varname)
 
CheckUnusedVar()
This constructor is used when registering the CheckClass.
 
void unusedVariableError(const Token *tok, const std::string &varname)
 
void unusedStructMemberError(const Token *tok, const std::string &structname, const std::string &varname, const std::string &prefix="struct")
 
void checkStructMemberUsage()
Check that all struct members are used
 
static std::string myName()
 
void unreadVariableError(const Token *tok, const std::string &varname, bool modified)
 
void checkFunctionVariableUsage()
 
CheckUnusedVar(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
This constructor is used when running checks.
 
std::map< const Type *, bool > mIsRecordTypeWithoutSideEffectsMap
 
Interface class that cppcheck uses to communicate with the checks.
 
This is an interface, which the class responsible of error logging should implement.
 
This is just a container for general settings so that we don't need to pass individual values to func...
 
The token list that the TokenList generates is a linked-list of this class.
 
The main purpose is to tokenize the source code.
 
const Settings & getSettings() const
 
Information about a class type.
 
Information about a member variable.
 
This class is used create a list of variables within a function.