Skip to content

Commit 2db1dbe

Browse files
committed
Changed some function prototypes according to cppcheck messages about functions that can be static.
1 parent 22a8e3f commit 2db1dbe

4 files changed

Lines changed: 12 additions & 13 deletions

File tree

cli/cmdlineparser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ CmdLineParser::CmdLineParser(Settings *settings)
9595
{
9696
}
9797

98-
void CmdLineParser::PrintMessage(const std::string &message) const
98+
void CmdLineParser::PrintMessage(const std::string &message)
9999
{
100100
std::cout << message << std::endl;
101101
}
@@ -705,7 +705,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
705705
return true;
706706
}
707707

708-
void CmdLineParser::PrintHelp() const
708+
void CmdLineParser::PrintHelp()
709709
{
710710
std::cout << "Cppcheck - A tool for static C/C++ code analysis\n"
711711
"\n"

cli/cmdlineparser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ class CmdLineParser {
9898
/**
9999
* Print help text to the console.
100100
*/
101-
void PrintHelp() const;
101+
static void PrintHelp();
102102

103103
/**
104104
* Print message (to console?).
105105
*/
106-
void PrintMessage(const std::string &message) const;
106+
static void PrintMessage(const std::string &message);
107107

108108
private:
109109
std::vector<std::string> _pathnames;

lib/checkmemoryleak.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ static int call_func_white_list_compare(const void *a, const void *b)
9999

100100
//---------------------------------------------------------------------------
101101

102-
bool CheckMemoryLeak::isclass(const Tokenizer *_tokenizer, const Token *tok, unsigned int varid) const
102+
bool CheckMemoryLeak::isclass(const Token *tok, unsigned int varid) const
103103
{
104104
if (tok->isStandardType())
105105
return false;
106106

107-
const Variable * var = _tokenizer->getSymbolDatabase()->getVariableFromVarId(varid);
107+
const Variable * var = tokenizer->getSymbolDatabase()->getVariableFromVarId(varid);
108108

109109
// return false if the type is a simple record type without side effects
110110
// a type that has no side effects (no constructors and no members with constructors)
@@ -566,7 +566,7 @@ void CheckMemoryLeakInFunction::parse_noreturn()
566566
}
567567

568568

569-
bool CheckMemoryLeakInFunction::notvar(const Token *tok, unsigned int varid, bool endpar) const
569+
bool CheckMemoryLeakInFunction::notvar(const Token *tok, unsigned int varid, bool endpar)
570570
{
571571
const std::string end(endpar ? " &&|)" : " [;)&|]");
572572
return bool(Token::Match(tok, ("! %varid%" + end).c_str(), varid) ||
@@ -893,17 +893,17 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
893893
if (alloc == CheckMemoryLeak::New) {
894894
if (Token::Match(tok->tokAt(2), "new struct| %type% [(;]")) {
895895
const int offset = tok->strAt(3) == "struct" ? 1 : 0;
896-
if (isclass(_tokenizer, tok->tokAt(3 + offset), varid)) {
896+
if (isclass(tok->tokAt(3 + offset), varid)) {
897897
alloc = No;
898898
}
899899
} else if (Token::Match(tok->tokAt(2), "new ( nothrow ) struct| %type%")) {
900900
const int offset = tok->strAt(6) == "struct" ? 1 : 0;
901-
if (isclass(_tokenizer, tok->tokAt(6 + offset), varid)) {
901+
if (isclass(tok->tokAt(6 + offset), varid)) {
902902
alloc = No;
903903
}
904904
} else if (Token::Match(tok->tokAt(2), "new ( std :: nothrow ) struct| %type%")) {
905905
const int offset = tok->strAt(8) == "struct" ? 1 : 0;
906-
if (isclass(_tokenizer, tok->tokAt(8 + offset), varid)) {
906+
if (isclass(tok->tokAt(8 + offset), varid)) {
907907
alloc = No;
908908
}
909909
}

lib/checkmemoryleak.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,11 @@ class CPPCHECKLIB CheckMemoryLeak {
125125

126126
/**
127127
* @brief Is a typename the name of a class?
128-
* @param _tokenizer tokenizer
129128
* @param tok type token
130129
* @param varid variable id
131130
* @return true if the type name is the name of a class
132131
*/
133-
bool isclass(const Tokenizer *_tokenizer, const Token *tok, unsigned int varid) const;
132+
bool isclass(const Token *tok, unsigned int varid) const;
134133

135134
/**
136135
* Report that there is a memory leak (new/malloc/etc)
@@ -227,7 +226,7 @@ class CPPCHECKLIB CheckMemoryLeakInFunction : private Check, public CheckMemoryL
227226
* @param endpar if this is true the "!var" must be followed by ")"
228227
* @return true if match
229228
*/
230-
bool notvar(const Token *tok, unsigned int varid, bool endpar = false) const;
229+
static bool notvar(const Token *tok, unsigned int varid, bool endpar = false);
231230

232231
/**
233232
* Inspect a function call. the call_func and getcode are recursive

0 commit comments

Comments
 (0)