21 #ifndef checkfunctionsH
22 #define checkfunctionsH
58 :
Check(myName(), tokenizer, settings, errorLogger) {}
80 void checkProhibitedFunctions();
90 void invalidFunctionUsage();
93 void checkIgnoredReturnValue();
96 void checkMathFunctions();
99 void memsetZeroBytes();
102 void memsetInvalid2ndParam();
105 void returnLocalStdMove();
107 void useStandardLibrary();
110 void checkLibraryMatchFunctions();
113 void checkMissingReturn();
115 void invalidFunctionArgError(
const Token *tok,
const std::string &functionName,
int argnr,
const ValueFlow::Value *invalidValue,
const std::string &validstr);
116 void invalidFunctionArgBoolError(
const Token *tok,
const std::string &functionName,
int argnr);
117 void invalidFunctionArgStrError(
const Token *tok,
const std::string &functionName,
nonneg int argnr);
118 void ignoredReturnValueError(
const Token* tok,
const std::string&
function);
119 void ignoredReturnErrorCode(
const Token* tok,
const std::string&
function);
120 void mathfunctionCallWarning(
const Token *tok,
const nonneg int numParam = 1);
121 void mathfunctionCallWarning(
const Token *tok,
const std::string& oldexp,
const std::string& newexp);
122 void memsetZeroBytesError(
const Token *tok);
123 void memsetFloatError(
const Token *tok,
const std::string &var_value);
124 void memsetValueOutOfRangeError(
const Token *tok,
const std::string &value);
125 void missingReturnError(
const Token *tok);
126 void copyElisionError(
const Token *tok);
127 void useStandardLibraryError(
const Token *tok,
const std::string& expected);
151 return "Check function usage";
155 return "Check function usage:\n"
156 "- missing 'return' in non-void function\n"
157 "- return value of certain functions not used\n"
158 "- invalid input values for functions\n"
159 "- Warn if a function is called whose usage is discouraged\n"
160 "- memset() third argument is zero\n"
161 "- memset() with a value out of range as the 2nd parameter\n"
162 "- memset() with a float as the 2nd parameter\n"
163 "- copy elision optimization for returning value affected by std::move\n"
164 "- use memcpy()/memset() instead of for loop\n";
Check for bad function usage.
void checkMissingReturn()
Check for missing "return"
void checkProhibitedFunctions()
Check for functions that should not be used.
void memsetZeroBytes()
Check for filling zero bytes with memset()
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override
Run checks against the normal token list.
void ignoredReturnValueError(const Token *tok, const std::string &function)
void invalidFunctionArgError(const Token *tok, const std::string &functionName, int argnr, const ValueFlow::Value *invalidValue, const std::string &validstr)
void memsetZeroBytesError(const Token *tok)
void useStandardLibrary()
void invalidFunctionArgStrError(const Token *tok, const std::string &functionName, nonneg int argnr)
void checkIgnoredReturnValue()
Check for ignored return values.
void missingReturnError(const Token *tok)
CheckFunctions()
This constructor is used when registering the CheckFunctions.
void memsetValueOutOfRangeError(const Token *tok, const std::string &value)
void invalidFunctionUsage()
Invalid function usage (invalid input value / overlapping data)
void checkLibraryMatchFunctions()
–check-library: warn for unconfigured function calls
void mathfunctionCallWarning(const Token *tok, const nonneg int numParam=1)
void invalidFunctionArgBoolError(const Token *tok, const std::string &functionName, int argnr)
void useStandardLibraryError(const Token *tok, const std::string &expected)
void memsetInvalid2ndParam()
Check for invalid 2nd parameter of memset()
static std::string myName()
void checkMathFunctions()
Check for parameters given to math function that do not make sense
std::string classInfo() const override
get information about this class, used to generate documentation
void copyElisionError(const Token *tok)
void returnLocalStdMove()
Check for copy elision by RVO|NRVO
CheckFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
This constructor is used when running checks.
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override
get error messages
void memsetFloatError(const Token *tok, const std::string &var_value)
Interface class that cppcheck uses to communicate with the checks.
void reportError(const Token *tok, const Severity severity, const std::string &id, const std::string &msg)
report an error
This is an interface, which the class responsible of error logging should implement.
std::map< std::string, WarnInfo > functionwarn
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