Changed some function prototypes according to cppcheck messages about functions that can be static.
This commit is contained in:
parent
22a8e3f4e6
commit
2db1dbe2ce
|
@ -95,7 +95,7 @@ CmdLineParser::CmdLineParser(Settings *settings)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdLineParser::PrintMessage(const std::string &message) const
|
void CmdLineParser::PrintMessage(const std::string &message)
|
||||||
{
|
{
|
||||||
std::cout << message << std::endl;
|
std::cout << message << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -705,7 +705,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdLineParser::PrintHelp() const
|
void CmdLineParser::PrintHelp()
|
||||||
{
|
{
|
||||||
std::cout << "Cppcheck - A tool for static C/C++ code analysis\n"
|
std::cout << "Cppcheck - A tool for static C/C++ code analysis\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
|
@ -98,12 +98,12 @@ protected:
|
||||||
/**
|
/**
|
||||||
* Print help text to the console.
|
* Print help text to the console.
|
||||||
*/
|
*/
|
||||||
void PrintHelp() const;
|
static void PrintHelp();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print message (to console?).
|
* Print message (to console?).
|
||||||
*/
|
*/
|
||||||
void PrintMessage(const std::string &message) const;
|
static void PrintMessage(const std::string &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> _pathnames;
|
std::vector<std::string> _pathnames;
|
||||||
|
|
|
@ -99,12 +99,12 @@ static int call_func_white_list_compare(const void *a, const void *b)
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool CheckMemoryLeak::isclass(const Tokenizer *_tokenizer, const Token *tok, unsigned int varid) const
|
bool CheckMemoryLeak::isclass(const Token *tok, unsigned int varid) const
|
||||||
{
|
{
|
||||||
if (tok->isStandardType())
|
if (tok->isStandardType())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const Variable * var = _tokenizer->getSymbolDatabase()->getVariableFromVarId(varid);
|
const Variable * var = tokenizer->getSymbolDatabase()->getVariableFromVarId(varid);
|
||||||
|
|
||||||
// return false if the type is a simple record type without side effects
|
// return false if the type is a simple record type without side effects
|
||||||
// a type that has no side effects (no constructors and no members with constructors)
|
// a type that has no side effects (no constructors and no members with constructors)
|
||||||
|
@ -566,7 +566,7 @@ void CheckMemoryLeakInFunction::parse_noreturn()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CheckMemoryLeakInFunction::notvar(const Token *tok, unsigned int varid, bool endpar) const
|
bool CheckMemoryLeakInFunction::notvar(const Token *tok, unsigned int varid, bool endpar)
|
||||||
{
|
{
|
||||||
const std::string end(endpar ? " &&|)" : " [;)&|]");
|
const std::string end(endpar ? " &&|)" : " [;)&|]");
|
||||||
return bool(Token::Match(tok, ("! %varid%" + end).c_str(), varid) ||
|
return bool(Token::Match(tok, ("! %varid%" + end).c_str(), varid) ||
|
||||||
|
@ -893,17 +893,17 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
||||||
if (alloc == CheckMemoryLeak::New) {
|
if (alloc == CheckMemoryLeak::New) {
|
||||||
if (Token::Match(tok->tokAt(2), "new struct| %type% [(;]")) {
|
if (Token::Match(tok->tokAt(2), "new struct| %type% [(;]")) {
|
||||||
const int offset = tok->strAt(3) == "struct" ? 1 : 0;
|
const int offset = tok->strAt(3) == "struct" ? 1 : 0;
|
||||||
if (isclass(_tokenizer, tok->tokAt(3 + offset), varid)) {
|
if (isclass(tok->tokAt(3 + offset), varid)) {
|
||||||
alloc = No;
|
alloc = No;
|
||||||
}
|
}
|
||||||
} else if (Token::Match(tok->tokAt(2), "new ( nothrow ) struct| %type%")) {
|
} else if (Token::Match(tok->tokAt(2), "new ( nothrow ) struct| %type%")) {
|
||||||
const int offset = tok->strAt(6) == "struct" ? 1 : 0;
|
const int offset = tok->strAt(6) == "struct" ? 1 : 0;
|
||||||
if (isclass(_tokenizer, tok->tokAt(6 + offset), varid)) {
|
if (isclass(tok->tokAt(6 + offset), varid)) {
|
||||||
alloc = No;
|
alloc = No;
|
||||||
}
|
}
|
||||||
} else if (Token::Match(tok->tokAt(2), "new ( std :: nothrow ) struct| %type%")) {
|
} else if (Token::Match(tok->tokAt(2), "new ( std :: nothrow ) struct| %type%")) {
|
||||||
const int offset = tok->strAt(8) == "struct" ? 1 : 0;
|
const int offset = tok->strAt(8) == "struct" ? 1 : 0;
|
||||||
if (isclass(_tokenizer, tok->tokAt(8 + offset), varid)) {
|
if (isclass(tok->tokAt(8 + offset), varid)) {
|
||||||
alloc = No;
|
alloc = No;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,12 +125,11 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Is a typename the name of a class?
|
* @brief Is a typename the name of a class?
|
||||||
* @param _tokenizer tokenizer
|
|
||||||
* @param tok type token
|
* @param tok type token
|
||||||
* @param varid variable id
|
* @param varid variable id
|
||||||
* @return true if the type name is the name of a class
|
* @return true if the type name is the name of a class
|
||||||
*/
|
*/
|
||||||
bool isclass(const Tokenizer *_tokenizer, const Token *tok, unsigned int varid) const;
|
bool isclass(const Token *tok, unsigned int varid) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report that there is a memory leak (new/malloc/etc)
|
* Report that there is a memory leak (new/malloc/etc)
|
||||||
|
@ -227,7 +226,7 @@ public:
|
||||||
* @param endpar if this is true the "!var" must be followed by ")"
|
* @param endpar if this is true the "!var" must be followed by ")"
|
||||||
* @return true if match
|
* @return true if match
|
||||||
*/
|
*/
|
||||||
bool notvar(const Token *tok, unsigned int varid, bool endpar = false) const;
|
static bool notvar(const Token *tok, unsigned int varid, bool endpar = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inspect a function call. the call_func and getcode are recursive
|
* Inspect a function call. the call_func and getcode are recursive
|
||||||
|
|
Loading…
Reference in New Issue