From fae40c4782745dcd0bdbeb5a6f22230b850807ca Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sun, 8 Jul 2012 23:39:46 +0200 Subject: [PATCH] Change every C version of 'size_t' to C++ 'std::size_t'. --- cli/cppcheckexecutor.cpp | 14 +++++++------- cli/cppcheckexecutor.h | 6 +++--- cli/filelister.cpp | 12 ++++++------ cli/filelister.h | 4 ++-- cli/pathmatch.cpp | 2 +- cli/threadexecutor.cpp | 12 ++++++------ cli/threadexecutor.h | 4 ++-- lib/checkbufferoverrun.cpp | 6 +++--- lib/checkclass.cpp | 8 ++++---- lib/checkio.cpp | 4 ++-- lib/cppcheck.cpp | 8 ++++---- lib/cppcheck.h | 4 ++-- lib/errorlogger.h | 2 +- lib/preprocessor.cpp | 16 ++++++++-------- lib/settings.cpp | 2 +- lib/symboldatabase.cpp | 12 ++++++------ lib/symboldatabase.h | 4 ++-- lib/templatesimplifier.cpp | 2 +- lib/templatesimplifier.h | 2 +- lib/token.cpp | 4 ++-- lib/tokenize.cpp | 8 ++++---- test/testfilelister.cpp | 4 ++-- test/testrunner.cpp | 2 +- test/testsuite.cpp | 8 ++++---- test/testsuite.h | 8 ++++---- test/testsuppressions.cpp | 4 ++-- test/testthreadexecutor.cpp | 4 ++-- 27 files changed, 83 insertions(+), 83 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 0ca86722a..7af5183dc 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -124,7 +124,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c const bool caseSensitive = true; #endif PathMatch matcher(parser.GetIgnoredPaths(), caseSensitive); - for (std::map::iterator i = _files.begin(); i != _files.end();) { + for (std::map::iterator i = _files.begin(); i != _files.end();) { if (matcher.Match(i->first)) _files.erase(i++); else @@ -167,14 +167,14 @@ int CppCheckExecutor::check(int argc, const char* const argv[]) if (settings._jobs == 1) { // Single process - size_t totalfilesize = 0; - for (std::map::const_iterator i = _files.begin(); i != _files.end(); ++i) { + std::size_t totalfilesize = 0; + for (std::map::const_iterator i = _files.begin(); i != _files.end(); ++i) { totalfilesize += i->second; } - size_t processedsize = 0; + std::size_t processedsize = 0; unsigned int c = 0; - for (std::map::const_iterator i = _files.begin(); i != _files.end(); ++i) { + for (std::map::const_iterator i = _files.begin(); i != _files.end(); ++i) { returnValue += cppCheck.check(i->first); processedsize += i->second; if (!settings._errorsOnly) @@ -237,7 +237,7 @@ void CppCheckExecutor::reportOut(const std::string &outmsg) std::cout << outmsg << std::endl; } -void CppCheckExecutor::reportProgress(const std::string &filename, const char stage[], const size_t value) +void CppCheckExecutor::reportProgress(const std::string &filename, const char stage[], const std::size_t value) { (void)filename; @@ -270,7 +270,7 @@ void CppCheckExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg) reportErr(msg); } -void CppCheckExecutor::reportStatus(size_t fileindex, size_t filecount, size_t sizedone, size_t sizetotal) +void CppCheckExecutor::reportStatus(std::size_t fileindex, std::size_t filecount, std::size_t sizedone, std::size_t sizetotal) { if (filecount > 1) { std::ostringstream oss; diff --git a/cli/cppcheckexecutor.h b/cli/cppcheckexecutor.h index 5b02aeb97..a00eb2819 100644 --- a/cli/cppcheckexecutor.h +++ b/cli/cppcheckexecutor.h @@ -70,7 +70,7 @@ public: /** xml output of errors */ virtual void reportErr(const ErrorLogger::ErrorMessage &msg); - void reportProgress(const std::string &filename, const char stage[], const size_t value); + void reportProgress(const std::string &filename, const char stage[], const std::size_t value); /** * Output information messages. @@ -85,7 +85,7 @@ public: * @param sizedone The sum of sizes of the files checked. * @param sizetotal The total sizes of the files. */ - static void reportStatus(size_t fileindex, size_t filecount, size_t sizedone, size_t sizetotal); + static void reportStatus(std::size_t fileindex, std::size_t filecount, std::size_t sizedone, std::size_t sizetotal); protected: @@ -121,7 +121,7 @@ private: /** * Filename associated with size of file */ - std::map _files; + std::map _files; /** * Report progress time diff --git a/cli/filelister.cpp b/cli/filelister.cpp index 839f7dfe2..1a5f70235 100644 --- a/cli/filelister.cpp +++ b/cli/filelister.cpp @@ -118,7 +118,7 @@ static BOOL MyFileExists(const std::string& path) #endif // defined(UNICODE) -void FileLister::recursiveAddFiles(std::map &files, const std::string &path) +void FileLister::recursiveAddFiles(std::map &files, const std::string &path) { // oss is the search string passed into FindFirst and FindNext. // bdir is the base directory which is used to form pathnames. @@ -161,7 +161,7 @@ void FileLister::recursiveAddFiles(std::map &files, const s continue; #if defined(UNICODE) - size_t length = wcslen(ffd.cFileName); + std::size_t length = wcslen(ffd.cFileName); char * ansiFfd = new char[length + 1]; TransformUcs2ToAnsi(ffd.cFileName, ansiFfd, length + 1); #else // defined(UNICODE) @@ -182,7 +182,7 @@ void FileLister::recursiveAddFiles(std::map &files, const s const std::string nativename = Path::fromNativeSeparators(fname.str()); // Limitation: file sizes are assumed to fit in a 'size_t' #ifdef _WIN64 - files[nativename] = (static_cast(ffd.nFileSizeHigh) << 32) | ffd.nFileSizeLow; + files[nativename] = (static_cast(ffd.nFileSizeHigh) << 32) | ffd.nFileSizeLow; #else files[nativename] = ffd.nFileSizeLow; #endif @@ -246,7 +246,7 @@ std::string FileLister::getAbsolutePath(const std::string& path) } void FileLister::recursiveAddFiles2(std::set &seen_paths, - std::map &files, + std::map &files, const std::string &path) { std::ostringstream oss; @@ -279,7 +279,7 @@ void FileLister::recursiveAddFiles2(std::set &seen_paths, struct stat sb; if (stat(absolute_path.c_str(), &sb) == 0) { // Limitation: file sizes are assumed to fit in a 'size_t' - files[filename] = static_cast(sb.st_size); + files[filename] = static_cast(sb.st_size); } else files[filename] = 0; } @@ -294,7 +294,7 @@ void FileLister::recursiveAddFiles2(std::set &seen_paths, } -void FileLister::recursiveAddFiles(std::map &files, const std::string &path) +void FileLister::recursiveAddFiles(std::map &files, const std::string &path) { std::set seen_paths; recursiveAddFiles2(seen_paths, files, path); diff --git a/cli/filelister.h b/cli/filelister.h index b2a31604f..90e2c7a62 100644 --- a/cli/filelister.h +++ b/cli/filelister.h @@ -37,7 +37,7 @@ public: * @param files output map that associates the size of each file with its name * @param path root path */ - static void recursiveAddFiles(std::map &files, const std::string &path); + static void recursiveAddFiles(std::map &files, const std::string &path); /** * @brief Is given path a directory? @@ -55,7 +55,7 @@ public: static std::string getAbsolutePath(const std::string& path); static void recursiveAddFiles2(std::set &seen_paths, - std::map &files, + std::map &files, const std::string &path); #endif }; diff --git a/cli/pathmatch.cpp b/cli/pathmatch.cpp index 02c82f0c6..41c7cdc5c 100644 --- a/cli/pathmatch.cpp +++ b/cli/pathmatch.cpp @@ -74,6 +74,6 @@ bool PathMatch::Match(const std::string &path) const std::string PathMatch::RemoveFilename(const std::string &path) { - const size_t ind = path.find_last_of('/'); + const std::size_t ind = path.find_last_of('/'); return path.substr(0, ind + 1); } diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index 52000458d..db2696825 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -34,7 +34,7 @@ #include #endif -ThreadExecutor::ThreadExecutor(const std::map &files, Settings &settings, ErrorLogger &errorLogger) +ThreadExecutor::ThreadExecutor(const std::map &files, Settings &settings, ErrorLogger &errorLogger) : _files(files), _settings(settings), _errorLogger(errorLogger), _fileCount(0) { #ifdef THREADING_MODEL_FORK @@ -125,16 +125,16 @@ unsigned int ThreadExecutor::check() _fileCount = 0; unsigned int result = 0; - size_t totalfilesize = 0; - for (std::map::const_iterator i = _files.begin(); i != _files.end(); ++i) { + std::size_t totalfilesize = 0; + for (std::map::const_iterator i = _files.begin(); i != _files.end(); ++i) { totalfilesize += i->second; } std::list rpipes; std::map childFile; std::map pipeFile; - size_t processedsize = 0; - std::map::const_iterator i = _files.begin(); + std::size_t processedsize = 0; + std::map::const_iterator i = _files.begin(); for (;;) { // Start a new child if (i != _files.end() && rpipes.size() < _settings._jobs) { @@ -207,7 +207,7 @@ unsigned int ThreadExecutor::check() if (p != pipeFile.end()) { std::string name = p->second; pipeFile.erase(p); - std::map::const_iterator fs = _files.find(name); + std::map::const_iterator fs = _files.find(name); if (fs != _files.end()) { size = fs->second; } diff --git a/cli/threadexecutor.h b/cli/threadexecutor.h index 312d0829d..7d57ed4ca 100644 --- a/cli/threadexecutor.h +++ b/cli/threadexecutor.h @@ -39,7 +39,7 @@ class Settings; */ class ThreadExecutor : public ErrorLogger { public: - ThreadExecutor(const std::map &files, Settings &settings, ErrorLogger &_errorLogger); + ThreadExecutor(const std::map &files, Settings &settings, ErrorLogger &_errorLogger); virtual ~ThreadExecutor(); unsigned int check(); virtual void reportOut(const std::string &outmsg); @@ -56,7 +56,7 @@ public: void addFileContent(const std::string &path, const std::string &content); private: - const std::map &_files; + const std::map &_files; Settings &_settings; ErrorLogger &_errorLogger; unsigned int _fileCount; diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 807d31ec0..85f8edf3c 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -972,12 +972,12 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector 0 ? std::string("strcat ( %varid% , %str% ) ;") : ("strcat ( " + varnames + " , %str% ) ;"); if (Token::Match(tok, strcatPattern.c_str(), varid)) { - size_t charactersAppend = 0; + std::size_t charactersAppend = 0; const Token *tok2 = tok; while (tok2 && Token::Match(tok2, strcatPattern.c_str(), varid)) { charactersAppend += Token::getStrLength(tok2->tokAt(4 + varc)); - if (charactersAppend >= static_cast(total_size)) { + if (charactersAppend >= static_cast(total_size)) { bufferOverrunError(tok2); break; } @@ -1882,7 +1882,7 @@ CheckBufferOverrun::ArrayInfo::ArrayInfo(const CheckBufferOverrun::ArrayInfo &ai CheckBufferOverrun::ArrayInfo::ArrayInfo(const Variable *var, const Tokenizer *tokenizer) : _varname(var->name()), _varid(var->varId()) { - for (size_t i = 0; i < var->dimensions().size(); i++) + for (std::size_t i = 0; i < var->dimensions().size(); i++) _num.push_back(var->dimension(i)); if (var->typeEndToken()->str() == "*") _element_size = tokenizer->sizeOfType(var->typeEndToken()); diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index adbaf7ed6..03bf34fc4 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -197,13 +197,13 @@ void CheckClass::initVar(const std::string &varname, const Scope *scope, std::ve void CheckClass::assignAllVar(std::vector &usage) const { - for (size_t i = 0; i < usage.size(); ++i) + for (std::size_t i = 0; i < usage.size(); ++i) usage[i].assign = true; } void CheckClass::clearAllVar(std::vector &usage) const { - for (size_t i = 0; i < usage.size(); ++i) { + for (std::size_t i = 0; i < usage.size(); ++i) { usage[i].assign = false; usage[i].init = false; } @@ -212,7 +212,7 @@ void CheckClass::clearAllVar(std::vector &usage) const bool CheckClass::isBaseClassFunc(const Token *tok, const Scope *scope) { // Iterate through each base class... - for (size_t i = 0; i < scope->derivedFrom.size(); ++i) { + for (std::size_t i = 0; i < scope->derivedFrom.size(); ++i) { const Scope *derivedFrom = scope->derivedFrom[i].scope; // Check if base class exists in database @@ -716,7 +716,7 @@ void CheckClass::noMemset() void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Scope *type) { // recursively check all parent classes - for (size_t i = 0; i < type->derivedFrom.size(); i++) { + for (std::size_t i = 0; i < type->derivedFrom.size(); i++) { if (type->derivedFrom[i].scope) checkMemsetType(start, tok, type->derivedFrom[i].scope); } diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 394e42d70..8e699f3a5 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -99,8 +99,8 @@ void CheckIO::checkFileUsage() std::map filepointers; const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase(); - size_t varListSize = symbolDatabase->getVariableListSize(); - for (size_t i = 1; i < varListSize; ++i) { + std::size_t varListSize = symbolDatabase->getVariableListSize(); + for (std::size_t i = 1; i < varListSize; ++i) { const Variable* var = symbolDatabase->getVariableFromVarId(i); if (!var || !var->varId() || !Token::Match(var->typeStartToken(), "FILE *")) continue; diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index f31d0846d..25468fc11 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -75,7 +75,7 @@ unsigned int CppCheck::check(const std::string &path, const std::string &content void CppCheck::replaceAll(std::string& code, const std::string &from, const std::string &to) { - size_t pos = 0; + std::size_t pos = 0; while ((pos = code.find(from, pos)) != std::string::npos) { code.replace(pos, from.length(), to); pos += to.length(); @@ -96,7 +96,7 @@ bool CppCheck::findError(std::string code, const char FileName[]) for (;;) { // Try to remove included files from the source - size_t found=previousCode.rfind("\n#endfile"); + std::size_t found = previousCode.rfind("\n#endfile"); if (found == std::string::npos) { // No modifications can be done to the code } else { @@ -506,7 +506,7 @@ void CppCheck::reportOut(const std::string &outmsg) _errorLogger.reportOut(outmsg); } -void CppCheck::reportProgress(const std::string &filename, const char stage[], const size_t value) +void CppCheck::reportProgress(const std::string &filename, const char stage[], const std::size_t value) { _errorLogger.reportProgress(filename, stage, value); } @@ -516,7 +516,7 @@ void CppCheck::reportInfo(const ErrorLogger::ErrorMessage &msg) _errorLogger.reportInfo(msg); } -void CppCheck::reportStatus(unsigned int /*fileindex*/, unsigned int /*filecount*/, size_t /*sizedone*/, size_t /*sizetotal*/) +void CppCheck::reportStatus(unsigned int /*fileindex*/, unsigned int /*filecount*/, std::size_t /*sizedone*/, std::size_t /*sizetotal*/) { } diff --git a/lib/cppcheck.h b/lib/cppcheck.h index 650290944..8fdf9fdd0 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -104,7 +104,7 @@ public: */ static const char * extraVersion(); - virtual void reportStatus(unsigned int fileindex, unsigned int filecount, size_t sizedone, size_t sizetotal); + virtual void reportStatus(unsigned int fileindex, unsigned int filecount, std::size_t sizedone, std::size_t sizetotal); /** * @brief Terminate checking. The checking will be terminated as soon as possible. @@ -173,7 +173,7 @@ private: std::string _fileContent; std::set _dependencies; - void reportProgress(const std::string &filename, const char stage[], const size_t value); + void reportProgress(const std::string &filename, const char stage[], const std::size_t value); /** * Output information messages. diff --git a/lib/errorlogger.h b/lib/errorlogger.h index c6d17349d..34ae6f029 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -276,7 +276,7 @@ public: * @param stage for example preprocess / tokenize / simplify / check * @param value progress value (0-100) */ - virtual void reportProgress(const std::string &filename, const char stage[], const size_t value) { + virtual void reportProgress(const std::string &filename, const char stage[], const std::size_t value) { (void)filename; (void)stage; (void)value; diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index bd9d97523..1b7a5db3b 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -392,7 +392,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri // Remove comments.. if (str.compare(i, 2, "//", 0, 2) == 0) { - size_t commentStart = i + 2; + std::size_t commentStart = i + 2; i = str.find('\n', i); if (i == std::string::npos) break; @@ -417,7 +417,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri previous = '\n'; ++lineno; } else if (str.compare(i, 2, "/*", 0, 2) == 0) { - size_t commentStart = i + 2; + std::size_t commentStart = i + 2; unsigned char chPrev = 0; ++i; while (i < str.length() && (chPrev != '*' || ch != '/')) { @@ -454,7 +454,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri if (!suppressionIDs.empty()) { if (_settings != NULL) { // Add the suppressions. - for (size_t j(0); j < suppressionIDs.size(); ++j) { + for (std::size_t j = 0; j < suppressionIDs.size(); ++j) { const std::string errmsg(_settings->nomsg.addSuppression(suppressionIDs[j], filename, lineno)); if (!errmsg.empty()) { writeError(filename, lineno, _errorLogger, "cppcheckError", errmsg); @@ -482,7 +482,7 @@ std::string Preprocessor::removeComments(const std::string &str, const std::stri if (!suppressionIDs.empty()) { if (_settings != NULL) { // Add the suppressions. - for (size_t j(0); j < suppressionIDs.size(); ++j) { + for (std::size_t j = 0; j < suppressionIDs.size(); ++j) { const std::string errmsg(_settings->nomsg.addSuppression(suppressionIDs[j], filename, lineno)); if (!errmsg.empty()) { writeError(filename, lineno, _errorLogger, "cppcheckError", errmsg); @@ -1160,7 +1160,7 @@ std::list Preprocessor::getcfgs(const std::string &filedata, const } // Remove defined constants from ifdef configurations.. - size_t count = 0; + std::size_t count = 0; for (std::list::iterator it = ret.begin(); it != ret.end(); ++it) { if (_errorLogger) _errorLogger->reportProgress(filename, "Preprocessing (get configurations 2)", (100 * count++) / ret.size()); @@ -2655,7 +2655,7 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file // * when pos goes beyond a limit the limit needs to be // deleted because it is unsafe to insert/delete text // after the limit otherwise - std::map limits; + std::map limits; // pos is the current position in line std::string::size_type pos = 0; @@ -2717,7 +2717,7 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file // check that pos is within allowed limits for this // macro { - const std::map::const_iterator it2 = limits.find(macro); + const std::map::const_iterator it2 = limits.find(macro); if (it2 != limits.end() && pos <= line.length() - it2->second) break; } @@ -2777,7 +2777,7 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file ++pos2; // Remove old limits - for (std::map::iterator iter = limits.begin(); + for (std::map::iterator iter = limits.begin(); iter != limits.end();) { if ((line.length() - pos1) < iter->second) { // We have gone past this limit, so just delete it diff --git a/lib/settings.cpp b/lib/settings.cpp index c6068d885..34ffa3230 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -146,7 +146,7 @@ bool Settings::platform(PlatformType type) sizeof_float = sizeof(float); sizeof_double = sizeof(double); sizeof_long_double = sizeof(long double); - sizeof_size_t = sizeof(size_t); + sizeof_size_t = sizeof(std::size_t); sizeof_pointer = sizeof(void *); return true; case Win32W: diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 81260f0bf..ce998986c 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -743,11 +743,11 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti } /* set all unknown array dimensions that are set by a variable to the maximum size of that variable type */ - for (size_t i = 1; i <= _tokenizer->varIdCount(); i++) { + for (std::size_t i = 1; i <= _tokenizer->varIdCount(); i++) { // check each array variable if (_variableList[i] && _variableList[i]->isArray()) { // check each array dimension - for (size_t j = 0; j < _variableList[i]->dimensions().size(); j++) { + for (std::size_t j = 0; j < _variableList[i]->dimensions().size(); j++) { // check for a single token dimension that is a variable if (_variableList[i]->dimensions()[j].start && (_variableList[i]->dimensions()[j].start == _variableList[i]->dimensions()[j].end) && @@ -1362,7 +1362,7 @@ void SymbolDatabase::printVariable(const Variable *var, const char *indent) cons std::cout << "none" << std::endl; std::cout << indent << "_dimensions:"; - for (size_t i = 0; i < var->dimensions().size(); i++) { + for (std::size_t i = 0; i < var->dimensions().size(); i++) { std::cout << " " << var->dimension(i); } std::cout << std::endl; @@ -1463,8 +1463,8 @@ void SymbolDatabase::printOut(const char *title) const std::cout << " derivedFrom[" << scope->derivedFrom.size() << "] = ("; - size_t count = scope->derivedFrom.size(); - for (size_t i = 0; i < scope->derivedFrom.size(); ++i) { + std::size_t count = scope->derivedFrom.size(); + for (std::size_t i = 0; i < scope->derivedFrom.size(); ++i) { if (scope->derivedFrom[i].isVirtual) std::cout << "Virtual "; @@ -1538,7 +1538,7 @@ void SymbolDatabase::printOut(const char *title) const std::cout << std::endl; } - for (size_t i = 0; i < _variableList.size(); i++) { + for (std::size_t i = 0; i < _variableList.size(); i++) { std::cout << "_variableList[" << i << "] = " << _variableList[i] << std::endl; } } diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index b3fe7dce0..e58f5d99a 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -573,11 +573,11 @@ public: return bool(classAndStructTypes.find(type) != classAndStructTypes.end()); } - const Variable *getVariableFromVarId(size_t varId) const { + const Variable *getVariableFromVarId(std::size_t varId) const { return _variableList[varId]; } - size_t getVariableListSize() const { + std::size_t getVariableListSize() const { return _variableList.size(); } diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 3816925ea..6fb36e93f 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -531,7 +531,7 @@ void TemplateSimplifier::simplifyTemplatesUseDefaultArgumentValues(const std::li } } -bool TemplateSimplifier::simplifyTemplatesInstantiateMatch(const Token *instance, const std::string &name, size_t numberOfArguments, const char patternAfter[]) +bool TemplateSimplifier::simplifyTemplatesInstantiateMatch(const Token *instance, const std::string &name, std::size_t numberOfArguments, const char patternAfter[]) { if (!Token::simpleMatch(instance, (name + " <").c_str())) return false; diff --git a/lib/templatesimplifier.h b/lib/templatesimplifier.h index e6bfc11d9..f834c4aaa 100644 --- a/lib/templatesimplifier.h +++ b/lib/templatesimplifier.h @@ -103,7 +103,7 @@ public: * @param patternAfter pattern that must match the tokens after the ">" * @return match => true */ - static bool simplifyTemplatesInstantiateMatch(const Token *instance, const std::string &name, size_t numberOfArguments, const char patternAfter[]); + static bool simplifyTemplatesInstantiateMatch(const Token *instance, const std::string &name, std::size_t numberOfArguments, const char patternAfter[]); /** * Match template declaration/instantiation diff --git a/lib/token.cpp b/lib/token.cpp index 26bdd9bed..a713b6a78 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -490,7 +490,7 @@ bool Token::simpleMatch(const Token *tok, const char pattern[]) next = pattern + strlen(pattern); while (*current) { - size_t length = static_cast(next - current); + std::size_t length = static_cast(next - current); if (!tok || length != tok->_str.length() || strncmp(current, tok->_str.c_str(), length)) return false; @@ -797,7 +797,7 @@ std::size_t Token::getStrLength(const Token *tok) { assert(tok != NULL); - size_t len = 0; + std::size_t len = 0; const std::string strValue(tok->strValue()); const char *str = strValue.c_str(); diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index aa701aac9..3cafdd09f 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3191,7 +3191,7 @@ void Tokenizer::simplifySizeof() else if (Token::Match(tok, "sizeof ( * %var% )") || Token::Match(tok, "sizeof ( %var% [ %num% ] )")) { // Some default value.. - size_t sz = 0; + std::size_t sz = 0; unsigned int varid = tok->tokAt((tok->strAt(2) == "*") ? 3 : 2)->varId(); if (varid != 0) { @@ -7771,8 +7771,8 @@ void Tokenizer::simplifyComma() // find token where return ends and also count commas if (inReturn) { - size_t commaCounter = 0; - size_t indentlevel = 0; + std::size_t commaCounter = 0; + std::size_t indentlevel = 0; for (Token *tok2 = startFrom; tok2; tok2 = tok2->next()) { if (tok2->str() == ";") { @@ -9059,7 +9059,7 @@ void Tokenizer::printUnknownTypes() ss << unknowns.size() << " unknown types:" << std::endl; std::set::const_iterator it; - size_t count = 1; + std::size_t count = 1; for (it = unknowns.begin(); it != unknowns.end(); ++it, ++count) ss << count << ": " << *it << std::endl; diff --git a/test/testfilelister.cpp b/test/testfilelister.cpp index 9b10f08e0..a15646f3f 100644 --- a/test/testfilelister.cpp +++ b/test/testfilelister.cpp @@ -74,11 +74,11 @@ private: void recursiveAddFiles() { // Recursively add add files.. - std::map files; + std::map files; FileLister::recursiveAddFiles(files, "."); // In case there are leading "./".. - for (std::map::iterator i = files.begin(); i != files.end();) { + for (std::map::iterator i = files.begin(); i != files.end();) { if (i->first.compare(0,2,"./") == 0) { files[i->first.substr(2)] = i->second; files.erase(i++); diff --git a/test/testrunner.cpp b/test/testrunner.cpp index db5e9a92b..980b862c7 100644 --- a/test/testrunner.cpp +++ b/test/testrunner.cpp @@ -24,7 +24,7 @@ int main(int argc, const char *argv[]) { options args(argc, argv); - size_t ret = TestFixture::runTests(args); + std::size_t ret = TestFixture::runTests(args); return (ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/test/testsuite.cpp b/test/testsuite.cpp index dbc8cbed0..9254f5a8f 100644 --- a/test/testsuite.cpp +++ b/test/testsuite.cpp @@ -58,9 +58,9 @@ public: std::ostringstream TestFixture::errmsg; unsigned int TestFixture::countTests; -size_t TestFixture::fails_counter = 0; -size_t TestFixture::todos_counter = 0; -size_t TestFixture::succeeded_todos_counter = 0; +std::size_t TestFixture::fails_counter = 0; +std::size_t TestFixture::todos_counter = 0; +std::size_t TestFixture::succeeded_todos_counter = 0; TestFixture::TestFixture(const std::string &_name) :classname(_name) @@ -229,7 +229,7 @@ void TestFixture::processOptions(const options& args) gcc_style_errors = args.gcc_style_errors(); } -size_t TestFixture::runTests(const options& args) +std::size_t TestFixture::runTests(const options& args) { std::string classname(args.which_test()); std::string testname(""); diff --git a/test/testsuite.h b/test/testsuite.h index ff39ad089..16f9cae81 100644 --- a/test/testsuite.h +++ b/test/testsuite.h @@ -30,9 +30,9 @@ class TestFixture : public ErrorLogger { private: static std::ostringstream errmsg; static unsigned int countTests; - static size_t fails_counter; - static size_t todos_counter; - static size_t succeeded_todos_counter; + static std::size_t fails_counter; + static std::size_t todos_counter; + static std::size_t succeeded_todos_counter; protected: std::string classname; @@ -65,7 +65,7 @@ public: virtual ~TestFixture() { } static void printTests(); - static size_t runTests(const options& args); + static std::size_t runTests(const options& args); }; #define TEST_CASE( NAME ) if ( runTest(#NAME) ) { if (quiet_tests) { REDIRECT; NAME(); } else { NAME ();} } diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 91e27c5f0..70a507624 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -132,7 +132,7 @@ private: errout.str(""); output.str(""); - std::map files; + std::map files; files["test.cpp"] = 1; Settings settings; @@ -143,7 +143,7 @@ private: ASSERT_EQUALS("", r); } ThreadExecutor executor(files, settings, *this); - for (std::map::const_iterator i = files.begin(); i != files.end(); ++i) + for (std::map::const_iterator i = files.begin(); i != files.end(); ++i) executor.addFileContent(i->first, code); executor.check(); diff --git a/test/testthreadexecutor.cpp b/test/testthreadexecutor.cpp index 667de7759..d9fb6404f 100644 --- a/test/testthreadexecutor.cpp +++ b/test/testthreadexecutor.cpp @@ -51,7 +51,7 @@ private: return; } - std::map filemap; + std::map filemap; for (int i = 1; i <= files; ++i) { std::ostringstream oss; oss << "file_" << i << ".cpp"; @@ -61,7 +61,7 @@ private: Settings settings; settings._jobs = jobs; ThreadExecutor executor(filemap, settings, *this); - for (std::map::const_iterator i = filemap.begin(); i != filemap.end(); ++i) + for (std::map::const_iterator i = filemap.begin(); i != filemap.end(); ++i) executor.addFileContent(i->first, data); ASSERT_EQUALS(result, executor.check());