diff --git a/lib/checkclass.h b/lib/checkclass.h index 0cf935329..b06e9307d 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -160,7 +160,7 @@ private: // operatorEqToSelf helper functions bool hasAllocation(const Function *func, const Scope* scope); - bool hasAssignSelf(const Function *func, const Token *rhs); + static bool hasAssignSelf(const Function *func, const Token *rhs); // checkConst helper functions bool isMemberVar(const Scope *scope, const Token *tok); @@ -180,7 +180,7 @@ private: bool init; }; - bool isBaseClassFunc(const Token *tok, const Scope *scope); + static bool isBaseClassFunc(const Token *tok, const Scope *scope); /** * @brief assign a variable in the varlist @@ -188,7 +188,7 @@ private: * @param scope pointer to variable Scope * @param usage reference to usage vector */ - void assignVar(const std::string &varname, const Scope *scope, std::vector &usage); + static void assignVar(const std::string &varname, const Scope *scope, std::vector &usage); /** * @brief initialize a variable in the varlist @@ -196,7 +196,7 @@ private: * @param scope pointer to variable Scope * @param usage reference to usage vector */ - void initVar(const std::string &varname, const Scope *scope, std::vector &usage); + static void initVar(const std::string &varname, const Scope *scope, std::vector &usage); /** * @brief set all variables in list assigned diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index ce687623e..ad2af2bbd 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -377,7 +377,7 @@ void CheckMemoryLeak::memleakUponReallocFailureError(const Token *tok, const std reportErr(tok, Severity::error, "memleakOnRealloc", "Common realloc mistake: \'" + varname + "\' nulled but not freed upon failure"); } -void CheckMemoryLeak::resourceLeakError(const Token *tok, const std::string &varname) +void CheckMemoryLeak::resourceLeakError(const Token *tok, const std::string &varname) const { std::string errmsg("Resource leak"); if (!varname.empty()) @@ -1387,7 +1387,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::listisClassOrStruct()) { // goto initial '{' - tok2 = initBaseInfo(new_scope, tok); + tok2 = new_scope->initBaseInfo(tok); // make sure we have valid code if (!tok2) { @@ -1152,7 +1152,7 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok) } } -const Token *SymbolDatabase::initBaseInfo(Scope *scope, const Token *tok) +const Token *Scope::initBaseInfo(const Token *tok) { // goto initial '{' const Token *tok2 = tok->tokAt(2); @@ -1236,7 +1236,7 @@ const Token *SymbolDatabase::initBaseInfo(Scope *scope, const Token *tok) } // save pattern for base class name - scope->derivedFrom.push_back(base); + derivedFrom.push_back(base); } tok2 = tok2->next(); } diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 849e37d4f..17940683d 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -493,6 +493,8 @@ public: type_, scope_)); } + const Token *initBaseInfo(const Token *tok); + /** @brief initialize varlist */ void getVariableList(); @@ -588,7 +590,6 @@ private: Function* addGlobalFunctionDecl(Scope*& scope, const Token*& tok, const Token *argStart, const Token* funcStart); Function* addGlobalFunction(Scope*& scope, const Token*& tok, const Token *argStart, const Token* funcStart); void addNewFunction(Scope **info, const Token **tok); - const Token *initBaseInfo(Scope *info, const Token *tok); bool isFunction(const Token *tok, const Scope* outerScope, const Token **funcStart, const Token **argStart) const; /** class/struct types */ diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index a1ed7863a..4e3a32a50 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5885,7 +5885,7 @@ bool Tokenizer::simplifyKnownVariablesGetData(unsigned int varid, Token **_tok2, return true; } -bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsigned int varid, const std::string &structname, std::string &value, unsigned int valueVarId, bool valueIsPointer, const Token * const valueToken, int indentlevel) +bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsigned int varid, const std::string &structname, std::string &value, unsigned int valueVarId, bool valueIsPointer, const Token * const valueToken, int indentlevel) const { const bool pointeralias(valueToken->isName() || Token::Match(valueToken, "& %var% [")); @@ -7440,12 +7440,12 @@ const char *Tokenizer::getParameterName(const Token *ftok, unsigned int par) //--------------------------------------------------------------------------- -void Tokenizer::syntaxError(const Token *tok) +void Tokenizer::syntaxError(const Token *tok) const { reportError(tok, Severity::error, "syntaxError", "syntax error"); } -void Tokenizer::syntaxError(const Token *tok, char c) +void Tokenizer::syntaxError(const Token *tok, char c) const { reportError(tok, Severity::error, "syntaxError", std::string("Invalid number of character (") + c + ") " + @@ -8722,7 +8722,7 @@ void Tokenizer::removeUnnecessaryQualification() } } -void Tokenizer::unnecessaryQualificationError(const Token *tok, const std::string &qualification) +void Tokenizer::unnecessaryQualificationError(const Token *tok, const std::string &qualification) const { reportError(tok, Severity::portability, "unnecessaryQualification", "The extra qualification \'" + qualification + "\' is unnecessary and is considered an error by many compilers."); diff --git a/lib/tokenize.h b/lib/tokenize.h index 796651f18..49b22956f 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -329,13 +329,13 @@ public: * Utility function for simplifyKnownVariables. Get data about an * assigned variable. */ - bool simplifyKnownVariablesGetData(unsigned int varid, Token **_tok2, Token **_tok3, std::string &value, unsigned int &valueVarId, bool &valueIsPointer, bool floatvar); + static bool simplifyKnownVariablesGetData(unsigned int varid, Token **_tok2, Token **_tok3, std::string &value, unsigned int &valueVarId, bool &valueIsPointer, bool floatvar); /** * utility function for simplifyKnownVariables. Perform simplification * of a given variable */ - bool simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsigned int varid, const std::string &structname, std::string &value, unsigned int valueVarId, bool valueIsPointer, const Token * const valueToken, int indentlevel); + bool simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsigned int varid, const std::string &structname, std::string &value, unsigned int valueVarId, bool valueIsPointer, const Token * const valueToken, int indentlevel) const; /** Replace a "goto" with the statements */ void simplifyGoto(); @@ -465,7 +465,7 @@ public: * @param source The string to be modified, e.g. "\x61" * @return Modified string, e.g. "a" */ - std::string simplifyString(const std::string &source); + static std::string simplifyString(const std::string &source); /** * Use "<" comparison instead of ">" @@ -536,10 +536,10 @@ public: void createLinks2(); /** Syntax error */ - void syntaxError(const Token *tok); + void syntaxError(const Token *tok) const; /** Syntax error. Example: invalid number of ')' */ - void syntaxError(const Token *tok, char c); + void syntaxError(const Token *tok, char c) const; /** * assert that tokens are ok - used during debugging for example @@ -591,7 +591,7 @@ public: /** * unnecessary member qualification error */ - void unnecessaryQualificationError(const Token *tok, const std::string &qualification); + void unnecessaryQualificationError(const Token *tok, const std::string &qualification) const; /** * Remove Microsoft MFC 'DECLARE_MESSAGE_MAP()' diff --git a/test/testtoken.cpp b/test/testtoken.cpp index 670ea0027..fd96e468d 100644 --- a/test/testtoken.cpp +++ b/test/testtoken.cpp @@ -373,7 +373,7 @@ private: ASSERT_EQUALS(true, Token::Match(logicalAnd.tokens(), "%oror%|&&")); } - void append_vector(std::vector &dest, const std::vector &src) { + void append_vector(std::vector &dest, const std::vector &src) const { dest.insert(dest.end(), src.begin(), src.end()); }