Tokenizer: allow that time is measured for certain slow simplifications
This commit is contained in:
parent
6bae724cb6
commit
c7093ca5d6
|
@ -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;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "symboldatabase.h"
|
||||
#include "templatesimplifier.h"
|
||||
#include "preprocessor.h" // Preprocessor::macroChar
|
||||
#include "timer.h"
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
@ -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..
|
||||
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) {
|
||||
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...
|
||||
if (m_timerResults) {
|
||||
Timer t("Tokenizer::simplifyTokenList::setVarId", _settings->_showtime, m_timerResults);
|
||||
setVarId();
|
||||
} else {
|
||||
setVarId();
|
||||
}
|
||||
|
||||
bool modified = true;
|
||||
while (modified) {
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
|
Loading…
Reference in New Issue