21 #ifndef checkautovariablesH
22 #define checkautovariablesH
55 :
Check(myName(), tokenizer, settings, errorLogger) {}
66 void assignFunctionArg();
76 void checkVarLifetime();
78 void checkVarLifetimeScope(
const Token * start,
const Token * end);
90 void errorUselessAssignmentArg(
const Token *tok);
91 void errorUselessAssignmentPtrArg(
const Token *tok);
110 return "Auto Variables";
114 return "A pointer to a variable is only valid as long as the variable is in scope.\n"
116 "- returning a pointer to auto or temporary variable\n"
117 "- assigning address of an variable to an effective parameter of a function\n"
118 "- returning reference to local/temporary variable\n"
119 "- returning address of function parameter\n"
120 "- suspicious assignment of pointer argument\n"
121 "- useless assignment of function argument\n";
125 bool diag(
const Token* tokvalue);
Various small checks for automatic variables.
void errorUselessAssignmentPtrArg(const Token *tok)
void errorReturnReference(const Token *tok, ErrorPath errorPath, bool inconclusive)
void errorReturnDanglingLifetime(const Token *tok, const ValueFlow::Value *val)
void errorInvalidLifetime(const Token *tok, const ValueFlow::Value *val)
void errorDanglingTemporaryLifetime(const Token *tok, const ValueFlow::Value *val, const Token *tempTok)
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override
get error messages
std::string classInfo() const override
get information about this class, used to generate documentation
void errorDanglingTempReference(const Token *tok, ErrorPath errorPath, bool inconclusive)
static std::string myName()
void errorUselessAssignmentArg(const Token *tok)
void errorDanglingReference(const Token *tok, const Variable *var, ErrorPath errorPath)
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override
Run checks against the normal token list.
void errorAutoVariableAssignment(const Token *tok, bool inconclusive)
void assignFunctionArg()
assign function argument
CheckAutoVariables(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
This constructor is used when running checks.
CheckAutoVariables()
This constructor is used when registering the CheckClass.
void errorDanglngLifetime(const Token *tok, const ValueFlow::Value *val)
void autoVariables()
Check auto variables.
void errorInvalidDeallocation(const Token *tok, const ValueFlow::Value *val)
std::set< const Token * > mDiagDanglingTemp
void errorReturnTempReference(const Token *tok, ErrorPath errorPath, bool inconclusive)
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 member variable.
std::list< ErrorPathItem > ErrorPath