Fixed cppcheck messagesa about functions that can be const/static:

- Made Tokenizer::getErrorMessages static - Avoids creation of unnecessary instance of Tokenizer
- Changed Tokenizer::removeExceptionSpecifications to common style for simplification functions. In contrast to the comment, this function doesn't call itself recursivly - fixed comment.
- Made Tokenizer::IsScopeNoReturn static.
This commit is contained in:
PKEuS 2012-08-01 12:04:47 -07:00
parent 8594eca9cd
commit c8e40773f1
3 changed files with 10 additions and 15 deletions

View File

@ -543,8 +543,6 @@ void CppCheck::getErrorMessages()
for (std::list<Check *>::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)
(*it)->getErrorMessages(this, &_settings);
Tokenizer tokenizer(&_settings, 0);
tokenizer.getErrorMessages(this, &_settings);
Tokenizer::getErrorMessages(this, &_settings);
Preprocessor::getErrorMessages(this, &_settings);
}

View File

@ -1930,7 +1930,7 @@ bool Tokenizer::tokenize(std::istream &code,
simplifyConditionOperator();
// remove exception specifications..
removeExceptionSpecifications(list.front());
removeExceptionSpecifications();
// Collapse operator name tokens into single token
// operator = => operator=
@ -7334,7 +7334,7 @@ void Tokenizer::simplifyStd()
//---------------------------------------------------------------------------
bool Tokenizer::IsScopeNoReturn(const Token *endScopeToken, bool *unknown) const
bool Tokenizer::IsScopeNoReturn(const Token *endScopeToken, bool *unknown)
{
if (unknown)
*unknown = false;
@ -7834,9 +7834,9 @@ void Tokenizer::simplifyComma()
}
void Tokenizer::removeExceptionSpecifications(Token *tok) const
void Tokenizer::removeExceptionSpecifications()
{
while (tok) {
for(Token* tok = list.front(); tok; tok = tok->next()) {
if (Token::Match(tok, ") const| throw (")) {
if (tok->next()->str() == "const") {
Token::eraseTokens(tok->next(), tok->linkAt(3));
@ -7845,8 +7845,6 @@ void Tokenizer::removeExceptionSpecifications(Token *tok) const
Token::eraseTokens(tok, tok->linkAt(2));
tok->deleteNext();
}
tok = tok->next();
}
}
@ -8065,7 +8063,7 @@ void Tokenizer::simplifyConst()
}
}
void Tokenizer::getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const
void Tokenizer::getErrorMessages(ErrorLogger *errorLogger, const Settings *settings)
{
Tokenizer t(settings, errorLogger);
t.syntaxError(0, ' ');

View File

@ -72,7 +72,7 @@ public:
* \param unknown set to true if it's unknown if the scope is noreturn
* \return true if scope ends with a function call that might be 'noreturn'
*/
bool IsScopeNoReturn(const Token *endScopeToken, bool *unknown = 0) const;
static bool IsScopeNoReturn(const Token *endScopeToken, bool *unknown = 0);
/**
* Tokenize code
@ -171,7 +171,7 @@ public:
/**
* get error messages that the tokenizer generate
*/
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const;
static void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings);
/** Simplify assignment in function call "f(x=g());" => "x=g();f(x);"
*/
@ -525,10 +525,9 @@ public:
void simplifyFunctionPointers();
/**
* Remove exception specifications. This function calls itself recursively.
* @param tok First token in scope to cleanup
* Remove exception specifications.
*/
void removeExceptionSpecifications(Token *tok) const;
void removeExceptionSpecifications();
/**