diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 8ee7d0363..feaebc607 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -17,17 +17,15 @@ */ #include "cppcheck.h" -#include "preprocessor.h" // preprocessor. -#include "tokenize.h" // <- Tokenizer +#include "preprocessor.h" // Preprocessor +#include "tokenize.h" // Tokenizer #include "check.h" #include "path.h" #include -#include #include #include -#include #include "timer.h" #ifdef HAVE_RULES @@ -335,10 +333,6 @@ void CppCheck::checkFile(const std::string &code, const char FileName[]) return; } - Timer timer2("Tokenizer::fillFunctionList", _settings._showtime, &S_timerResults); - _tokenizer.fillFunctionList(); - timer2.Stop(); - // call all "runChecks" in all registered Check classes for (std::list::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it) { if (_settings.terminated()) @@ -357,10 +351,6 @@ void CppCheck::checkFile(const std::string &code, const char FileName[]) if (!result) return; - Timer timer4("Tokenizer::fillFunctionList", _settings._showtime, &S_timerResults); - _tokenizer.fillFunctionList(); - timer4.Stop(); - // call all "runSimplifiedChecks" in all registered Check classes for (std::list::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it) { if (_settings.terminated()) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 76613210b..684ccd624 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2587,7 +2587,6 @@ void Tokenizer::labels() if (Token::Match(tok, ") const| {")) { // Simplify labels in the executable scope.. unsigned int indentlevel = 0; - unsigned int indentroundbraces = 0; while (NULL != (tok = tok->next())) { if (tok->str() == "{") ++indentlevel; @@ -2595,27 +2594,21 @@ void Tokenizer::labels() --indentlevel; if (!indentlevel) break; - } + } else if (tok->str() == "(") + tok = tok->link(); - if (tok->str() == "(") - ++indentroundbraces; - else if (tok->str() == ")") { - if (!indentroundbraces) - break; - --indentroundbraces; - } - if (!indentroundbraces && tok->str() == "case") { + else if (tok->str() == "case") { while (NULL != (tok = tok->next())) { if (tok->str() == ":") break; } - if (!(tok->next()) || tok->next()->str() != ";") { + if (tok && (!(tok->next()) || tok->next()->str() != ";")) { tok->insertToken(";"); tok = tok->next(); } } // simplify label.. except for unhandled macro - if (!indentroundbraces && Token::Match(tok, "[;{}] %var% :") + if (Token::Match(tok, "[;{}] %var% :") && !Token::Match(tok->next(), "public|protected|private") && tok->strAt(3) != ";") { for (Token *tok2 = tok->tokAt(3); tok2; tok2 = tok2->next()) { @@ -7004,7 +6997,7 @@ bool Tokenizer::simplifyKnownVariablesSimplify(Token **tok2, Token *tok3, unsign if (Token::Match(tok3, ("%var% ( " + structname + " %varid% ,").c_str(), varid)) { const char * const functionName[] = { "memcmp","memcpy","memmove","memset", - "strcmp","strcpy","strncpy","strdup" + "strcmp","strcpy","strncmp","strncpy","strdup" }; for (unsigned int i = 0; i < (sizeof(functionName) / sizeof(*functionName)); ++i) { if (tok3->str() == functionName[i]) { @@ -8277,12 +8270,6 @@ const Token *Tokenizer::getFunctionTokenByName(const char funcname[]) const return NULL; } - -void Tokenizer::fillFunctionList() -{ - getSymbolDatabase(); -} - //--------------------------------------------------------------------------- // Deallocate lists.. diff --git a/lib/tokenize.h b/lib/tokenize.h index eeb37c57e..8595ac38c 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -27,7 +27,6 @@ #include #include #include -#include class Token; class ErrorLogger; @@ -181,9 +180,6 @@ public: */ const std::vector *getFiles() const; - /** recreate symbol database */ - void fillFunctionList(); - /** * Get function token by function name * @todo better handling of overloaded functions diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 9c41d65fb..24e365420 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -54,9 +54,6 @@ private: // Assign variable ids tokenizer.setVarId(); - // Fill function list - tokenizer.fillFunctionList(); - // Check auto variables checkAutoVariables.autoVariables(); checkAutoVariables.returnPointerToLocalArray(); diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index a2b104699..202ac5147 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -54,9 +54,6 @@ private: // Assign variable ids tokenizer.simplifyTokenList(); - // Fill function list - tokenizer.fillFunctionList(); - // Check for buffer overruns.. CheckBufferOverrun checkBufferOverrun(&tokenizer, &settings, this); checkBufferOverrun.bufferOverrun(); diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index ce03a3367..49930842f 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -135,8 +135,6 @@ private: tokenizer.setVarId(); tokenizer.simplifyTokenList(); - tokenizer.fillFunctionList(); - // Check for memory leaks.. CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, &settings, this); checkMemoryLeak.checkReallocUsage(); @@ -3789,8 +3787,6 @@ private: tokenizer.setVarId(); tokenizer.simplifyTokenList(); - tokenizer.fillFunctionList(); - // Check for memory leaks.. CheckMemoryLeakInClass checkMemoryLeak(&tokenizer, &settings, this); checkMemoryLeak.check(); diff --git a/test/testnonreentrantfunctions.cpp b/test/testnonreentrantfunctions.cpp index 55b3be191..0b0699a2c 100644 --- a/test/testnonreentrantfunctions.cpp +++ b/test/testnonreentrantfunctions.cpp @@ -54,9 +54,6 @@ private: // Assign variable ids tokenizer.setVarId(); - // Fill function list - tokenizer.fillFunctionList(); - // Check for non reentrant functions.. CheckNonReentrantFunctions checkNonReentrantFunctions(&tokenizer, &settings, this); checkNonReentrantFunctions.nonReentrantFunctions(); diff --git a/test/testobsoletefunctions.cpp b/test/testobsoletefunctions.cpp index 63f8551c0..bc8bba85f 100644 --- a/test/testobsoletefunctions.cpp +++ b/test/testobsoletefunctions.cpp @@ -86,9 +86,6 @@ private: // Assign variable ids tokenizer.setVarId(); - // Fill function list - tokenizer.fillFunctionList(); - // Check for obsolete functions.. CheckObsoleteFunctions checkObsoleteFunctions(&tokenizer, &settings, this); checkObsoleteFunctions.obsoleteFunctions(); diff --git a/test/testpostfixoperator.cpp b/test/testpostfixoperator.cpp index 9059955b5..17eaea16e 100644 --- a/test/testpostfixoperator.cpp +++ b/test/testpostfixoperator.cpp @@ -51,9 +51,6 @@ private: // Assign variable ids tokenizer.setVarId(); - // Fill function list - tokenizer.fillFunctionList(); - // Check for postfix operators.. CheckPostfixOperator checkPostfixOperator(&tokenizer, &settings, this); checkPostfixOperator.postfixOperator();