From d341b42b0c78be2f6387f2819ed6d11d8dbd65ba Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sun, 16 Jan 2011 18:13:54 +0100 Subject: [PATCH] Symbol database: increased constness. ticket: #2468 --- lib/checkclass.cpp | 14 +++++++------- lib/checkclass.h | 2 +- lib/checkmemoryleak.cpp | 12 ++++++------ lib/checkmemoryleak.h | 2 +- lib/checkother.cpp | 14 +++++++------- lib/tokenize.cpp | 6 +++--- lib/tokenize.h | 4 ++-- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index bc9b6be7a..4c71a0bf7 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -68,11 +68,11 @@ void CheckClass::constructors() createSymbolDatabase(); - std::list::iterator i; + std::list::const_iterator i; for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i) { - SymbolDatabase::SpaceInfo *info = *i; + const SymbolDatabase::SpaceInfo *info = *i; // only check classes and structures if (!info->isClassOrStruct()) @@ -569,11 +569,11 @@ void CheckClass::privateFunctions() createSymbolDatabase(); - std::list::iterator i; + std::list::const_iterator i; for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i) { - SymbolDatabase::SpaceInfo *info = *i; + const SymbolDatabase::SpaceInfo *info = *i; // only check classes and structures if (!info->isClassOrStruct()) @@ -1270,11 +1270,11 @@ void CheckClass::checkConst() createSymbolDatabase(); - std::list::iterator it; + std::list::const_iterator it; for (it = symbolDatabase->spaceInfoList.begin(); it != symbolDatabase->spaceInfoList.end(); ++it) { - SymbolDatabase::SpaceInfo *info = *it; + const SymbolDatabase::SpaceInfo *info = *it; // only check classes and structures if (!info->isClassOrStruct()) @@ -1353,7 +1353,7 @@ void CheckClass::checkConst() if (checkConstFunc(info, paramEnd)) { std::string classname = info->className; - SymbolDatabase::SpaceInfo *nest = info->nestedIn; + const SymbolDatabase::SpaceInfo *nest = info->nestedIn; while (nest && nest->type != SymbolDatabase::SpaceInfo::Global) { classname = std::string(nest->className + "::" + classname); diff --git a/lib/checkclass.h b/lib/checkclass.h index 23edb4dc0..9a8717720 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -110,7 +110,7 @@ private: */ void createSymbolDatabase(); - SymbolDatabase *symbolDatabase; + const SymbolDatabase *symbolDatabase; // Reporting errors.. void noConstructorError(const Token *tok, const std::string &classname, bool isStruct); diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 4ce6a918e..62d883e11 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -569,7 +569,7 @@ void CheckMemoryLeakInFunction::parse_noreturn() for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i) { - SymbolDatabase::SpaceInfo *info = *i; + const SymbolDatabase::SpaceInfo *info = *i; // only check functions if (info->type != SymbolDatabase::SpaceInfo::Function) @@ -2495,7 +2495,7 @@ void CheckMemoryLeakInFunction::checkReallocUsage() for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i) { - SymbolDatabase::SpaceInfo *info = *i; + const SymbolDatabase::SpaceInfo *info = *i; // only check functions if (info->type != SymbolDatabase::SpaceInfo::Function) @@ -2648,7 +2648,7 @@ void CheckMemoryLeakInFunction::check() for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i) { - SymbolDatabase::SpaceInfo *info = *i; + const SymbolDatabase::SpaceInfo *info = *i; // only check functions if (info->type != SymbolDatabase::SpaceInfo::Function) @@ -2699,9 +2699,9 @@ void CheckMemoryLeakInFunction::check() void CheckMemoryLeakInClass::check() { - SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); + const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); - std::list::iterator i; + std::list::const_iterator i; for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i) { @@ -3164,7 +3164,7 @@ void CheckMemoryLeakNoVar::check() c.analyse(_tokenizer->tokens(), uvarFunctions); } - SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); + const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); std::list::const_iterator i; diff --git a/lib/checkmemoryleak.h b/lib/checkmemoryleak.h index ecce46cb2..961b0d258 100644 --- a/lib/checkmemoryleak.h +++ b/lib/checkmemoryleak.h @@ -352,7 +352,7 @@ public: /** Function names for functions that are not "noreturn" */ std::set notnoreturn; - SymbolDatabase *symbolDatabase; + const SymbolDatabase *symbolDatabase; }; diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 3f47fe7b1..1a17e0d2e 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1234,13 +1234,13 @@ void CheckOther::functionVariableUsage() return; // Parse all executing scopes.. - SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); + const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); std::list::const_iterator i; for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i) { - SymbolDatabase::SpaceInfo *info = *i; + const SymbolDatabase::SpaceInfo *info = *i; // only check functions if (info->type != SymbolDatabase::SpaceInfo::Function) @@ -1902,13 +1902,13 @@ void CheckOther::checkVariableScope() if (!_settings->isEnabled("information")) return; - SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); + const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); std::list::const_iterator i; for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i) { - SymbolDatabase::SpaceInfo *info = *i; + const SymbolDatabase::SpaceInfo *info = *i; // only check functions if (info->type != SymbolDatabase::SpaceInfo::Function) @@ -2529,9 +2529,9 @@ void CheckOther::checkMisusedScopedObject() return; } - SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); + const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); - std::list::iterator i; + std::list::const_iterator i; // list of classes / structs std::set identifiers; @@ -2543,7 +2543,7 @@ void CheckOther::checkMisusedScopedObject() for (i = symbolDatabase->spaceInfoList.begin(); i != symbolDatabase->spaceInfoList.end(); ++i) { - SymbolDatabase::SpaceInfo *info = *i; + const SymbolDatabase::SpaceInfo *info = *i; // only check functions if (info->type != SymbolDatabase::SpaceInfo::Function) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 249ebc656..6e7441daa 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7954,11 +7954,11 @@ const Token *Tokenizer::getFunctionTokenByName(const char funcname[]) const if (_symbolDatabase == NULL) getSymbolDatabase(); - std::list::iterator i; + std::list::const_iterator i; for (i = _symbolDatabase->spaceInfoList.begin(); i != _symbolDatabase->spaceInfoList.end(); ++i) { - SymbolDatabase::SpaceInfo *info = *i; + const SymbolDatabase::SpaceInfo *info = *i; if (info->type == SymbolDatabase::SpaceInfo::Function) { @@ -9235,7 +9235,7 @@ void Tokenizer::simplifyQtSignalsSlots() } } -SymbolDatabase *Tokenizer::getSymbolDatabase() const +const SymbolDatabase *Tokenizer::getSymbolDatabase() const { if (!_symbolDatabase) _symbolDatabase = new SymbolDatabase(this, _settings, _errorLogger); diff --git a/lib/tokenize.h b/lib/tokenize.h index 749d836c2..318bdf4c4 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -572,9 +572,9 @@ public: _settings = settings; } - SymbolDatabase * getSymbolDatabase() const; + const SymbolDatabase *getSymbolDatabase() const; - Token * deleteInvalidTypedef(Token *typeDef); + Token *deleteInvalidTypedef(Token *typeDef); private: /** Disable copy constructor, no implementation */