From a9cfe2814a18192f1c089c1f78e8a8ad11d1cb06 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Thu, 17 May 2012 02:54:17 -0700 Subject: [PATCH] Made some functions const according to cppcheck results --- lib/checkother.cpp | 2 +- lib/tokenize.cpp | 10 +++++----- lib/tokenize.h | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 9afc56051..4c9f7e75f 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2752,7 +2752,7 @@ namespace { struct FuncFilter { FuncFilter(const Scope *scope, const Token *tok): _scope(scope), _tok(tok) {} - bool operator()(const Function &func) { + bool operator()(const Function &func) const { bool matchingFunc = func.type == Function::eFunction && _tok->str() == func.token->str(); // either a class function, or a global function with the same name diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 4e3a32a50..7f8d1fecd 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -131,7 +131,7 @@ Token *Tokenizer::copyTokens(Token *dest, const Token *first, const Token *last, //--------------------------------------------------------------------------- -void Tokenizer::duplicateTypedefError(const Token *tok1, const Token *tok2, const std::string &type) +void Tokenizer::duplicateTypedefError(const Token *tok1, const Token *tok2, const std::string &type) const { if (tok1 && !(_settings->isEnabled("style") && _settings->inconclusive)) return; @@ -145,7 +145,7 @@ void Tokenizer::duplicateTypedefError(const Token *tok1, const Token *tok2, cons std::string("The " + type + " '" + tok2_str + "' hides a typedef with the same name."), true); } -void Tokenizer::duplicateDeclarationError(const Token *tok1, const Token *tok2, const std::string &type) +void Tokenizer::duplicateDeclarationError(const Token *tok1, const Token *tok2, const std::string &type) const { if (tok1 && !(_settings->isEnabled("style"))) return; @@ -160,7 +160,7 @@ void Tokenizer::duplicateDeclarationError(const Token *tok1, const Token *tok2, } // check if this statement is a duplicate definition -bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token *typeDef, bool undefinedStruct) +bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token *typeDef, bool undefinedStruct) const { // check for an end of definition const Token * tok = *tokPtr; @@ -6675,7 +6675,7 @@ void Tokenizer::simplifyNestedStrcat() } -void Tokenizer::duplicateEnumError(const Token * tok1, const Token * tok2, const std::string & type) +void Tokenizer::duplicateEnumError(const Token * tok1, const Token * tok2, const std::string & type) const { if (tok1 && !(_settings->isEnabled("style"))) return; @@ -6692,7 +6692,7 @@ void Tokenizer::duplicateEnumError(const Token * tok1, const Token * tok2, const // Check if this statement is a duplicate definition. A duplicate // definition will hide the enumerator within it's scope so just // skip the entire scope of the duplicate. -bool Tokenizer::duplicateDefinition(Token ** tokPtr, const Token * name) +bool Tokenizer::duplicateDefinition(Token ** tokPtr, const Token * name) const { // check for an end of definition const Token * tok = *tokPtr; diff --git a/lib/tokenize.h b/lib/tokenize.h index 49b22956f..da737291d 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -642,7 +642,7 @@ public: /** * check for duplicate enum definition */ - bool duplicateDefinition(Token **tokPtr, const Token *name); + bool duplicateDefinition(Token **tokPtr, const Token *name) const; /** * report error message @@ -653,15 +653,15 @@ public: /** * duplicate enum definition error */ - void duplicateEnumError(const Token *tok1, const Token *tok2, const std::string & type); + void duplicateEnumError(const Token *tok1, const Token *tok2, const std::string & type) const; - bool duplicateTypedef(Token **tokPtr, const Token *name, const Token *typeDef, bool undefinedStruct); - void duplicateTypedefError(const Token *tok1, const Token *tok2, const std::string & type); + bool duplicateTypedef(Token **tokPtr, const Token *name, const Token *typeDef, bool undefinedStruct) const; + void duplicateTypedefError(const Token *tok1, const Token *tok2, const std::string & type) const; /** * Report error - duplicate declarations */ - void duplicateDeclarationError(const Token *tok1, const Token *tok2, const std::string &type); + void duplicateDeclarationError(const Token *tok1, const Token *tok2, const std::string &type) const; void unsupportedTypedef(const Token *tok) const;