49 :
Check(myName(), tokenizer, settings, errorLogger) {}
70 void sizeofCalculation();
73 void sizeofFunction();
76 void suspiciousSizeofCalculation();
79 void checkSizeofForArrayParameter();
82 void checkSizeofForPointerSize();
85 void checkSizeofForNumericParameter();
91 void sizeofsizeofError(
const Token* tok);
93 void sizeofFunctionError(
const Token* tok);
94 void multiplySizeofError(
const Token* tok);
95 void divideSizeofError(
const Token* tok);
96 void sizeofForArrayParameterError(
const Token* tok);
97 void sizeofForPointerError(
const Token* tok,
const std::string &varname);
98 void divideBySizeofError(
const Token* tok,
const std::string &memfunc);
99 void sizeofForNumericParameterError(
const Token* tok);
100 void sizeofVoidError(
const Token *tok);
101 void sizeofDereferencedVoidPointerError(
const Token *tok,
const std::string &varname);
102 void arithOperationsOnVoidPointerError(
const Token* tok,
const std::string &varname,
const std::string &vartype);
125 return "sizeof() usage checks\n"
126 "- sizeof for array given as function argument\n"
127 "- sizeof for numeric given as function argument\n"
128 "- using sizeof(pointer) instead of the size of pointed data\n"
129 "- look for 'sizeof sizeof ..'\n"
130 "- look for calculations inside sizeof()\n"
131 "- look for function calls inside sizeof()\n"
132 "- look for suspicious calculations with sizeof()\n"
133 "- using 'sizeof(void)' which is undefined\n";
checks on usage of sizeof() operator
void sizeofVoid()
Check for using sizeof(void)
void sizeofFunction()
Check for function call inside sizeof
void sizeofDereferencedVoidPointerError(const Token *tok, const std::string &varname)
void sizeofForArrayParameterError(const Token *tok)
CheckSizeof()
This constructor is used when registering the CheckClass.
void sizeofVoidError(const Token *tok)
void checkSizeofForNumericParameter()
Check for using sizeof with numeric given as function argument
void checkSizeofForPointerSize()
Check for using sizeof of a variable when allocating it
void suspiciousSizeofCalculation()
Check for suspicious calculations with sizeof results
void sizeofsizeofError(const Token *tok)
void sizeofForNumericParameterError(const Token *tok)
void divideBySizeofError(const Token *tok, const std::string &memfunc)
void checkSizeofForArrayParameter()
Check for using sizeof with array given as function argument
void divideSizeofError(const Token *tok)
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 sizeofsizeof()
Check for 'sizeof sizeof ..'
void multiplySizeofError(const Token *tok)
void sizeofFunctionError(const Token *tok)
void sizeofForPointerError(const Token *tok, const std::string &varname)
void arithOperationsOnVoidPointerError(const Token *tok, const std::string &varname, const std::string &vartype)
void sizeofCalculationError(const Token *tok, bool inconclusive)
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override
get error messages
CheckSizeof(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
This constructor is used when running checks.
static std::string myName()
void sizeofCalculation()
Check for calculations inside sizeof
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