diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index f581894fb..6dbaa2950 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -309,6 +309,8 @@ void CppCheck::checkFile(const std::string &code, const char FileName[]) return; Tokenizer _tokenizer(&_settings, this); + if (_settings._showtime != SHOWTIME_NONE) + _tokenizer.setTimerResults(&S_timerResults); try { bool result; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 8e2eef274..24084f60b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -28,6 +28,7 @@ #include "symboldatabase.h" #include "templatesimplifier.h" #include "preprocessor.h" // Preprocessor::macroChar +#include "timer.h" #include #include @@ -47,7 +48,8 @@ Tokenizer::Tokenizer() : _errorLogger(0), _symbolDatabase(0), _varId(0), - _codeWithTemplates(false) //is there any templates? + _codeWithTemplates(false), //is there any templates? + m_timerResults(NULL) { } @@ -58,7 +60,8 @@ Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger) : _errorLogger(errorLogger), _symbolDatabase(0), _varId(0), - _codeWithTemplates(false) //is there any templates? + _codeWithTemplates(false), //is there any templates? + m_timerResults(NULL) { // make sure settings are specified assert(_settings); @@ -2109,7 +2112,12 @@ bool Tokenizer::tokenize(std::istream &code, simplifyDebugNew(); // typedef.. - simplifyTypedef(); + if (m_timerResults) { + Timer t("Tokenizer::tokenize::simplifyTypedef", _settings->_showtime, m_timerResults); + simplifyTypedef(); + } else { + simplifyTypedef(); + } // catch bad typedef canonicalization // @@ -2298,7 +2306,12 @@ bool Tokenizer::tokenize(std::istream &code, simplifyVarDecl(false); if (!preprocessorCondition) { - setVarId(); + if (m_timerResults) { + Timer t("Tokenizer::tokenize::setVarId", _settings->_showtime, m_timerResults); + setVarId(); + } else { + setVarId(); + } createLinks2(); @@ -3743,7 +3756,12 @@ bool Tokenizer::simplifyTokenList() simplifyIfAssign(); // could be affected by simplifyIfNot // In case variable declarations have been updated... - setVarId(); + if (m_timerResults) { + Timer t("Tokenizer::simplifyTokenList::setVarId", _settings->_showtime, m_timerResults); + setVarId(); + } else { + setVarId(); + } bool modified = true; while (modified) { diff --git a/lib/tokenize.h b/lib/tokenize.h index ceeb1355a..45c6e7a13 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -34,6 +34,7 @@ class Token; class ErrorLogger; class Settings; class SymbolDatabase; +class TimerResults; /// @addtogroup Core /// @{ @@ -49,6 +50,10 @@ public: Tokenizer(const Settings * settings, ErrorLogger *errorLogger); ~Tokenizer(); + void setTimerResults(TimerResults *tr) { + m_timerResults = tr; + } + /** Returns the source file path. e.g. "file.cpp" */ const std::string& getSourceFilePath() const; @@ -781,6 +786,11 @@ private: * removed from the token list */ bool _codeWithTemplates; + + /** + * TimerResults + */ + TimerResults *m_timerResults; }; /// @}