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;
|
return;
|
||||||
|
|
||||||
Tokenizer _tokenizer(&_settings, this);
|
Tokenizer _tokenizer(&_settings, this);
|
||||||
|
if (_settings._showtime != SHOWTIME_NONE)
|
||||||
|
_tokenizer.setTimerResults(&S_timerResults);
|
||||||
try {
|
try {
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "symboldatabase.h"
|
#include "symboldatabase.h"
|
||||||
#include "templatesimplifier.h"
|
#include "templatesimplifier.h"
|
||||||
#include "preprocessor.h" // Preprocessor::macroChar
|
#include "preprocessor.h" // Preprocessor::macroChar
|
||||||
|
#include "timer.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -47,7 +48,8 @@ Tokenizer::Tokenizer() :
|
||||||
_errorLogger(0),
|
_errorLogger(0),
|
||||||
_symbolDatabase(0),
|
_symbolDatabase(0),
|
||||||
_varId(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),
|
_errorLogger(errorLogger),
|
||||||
_symbolDatabase(0),
|
_symbolDatabase(0),
|
||||||
_varId(0),
|
_varId(0),
|
||||||
_codeWithTemplates(false) //is there any templates?
|
_codeWithTemplates(false), //is there any templates?
|
||||||
|
m_timerResults(NULL)
|
||||||
{
|
{
|
||||||
// make sure settings are specified
|
// make sure settings are specified
|
||||||
assert(_settings);
|
assert(_settings);
|
||||||
|
@ -2109,7 +2112,12 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
simplifyDebugNew();
|
simplifyDebugNew();
|
||||||
|
|
||||||
// typedef..
|
// typedef..
|
||||||
simplifyTypedef();
|
if (m_timerResults) {
|
||||||
|
Timer t("Tokenizer::tokenize::simplifyTypedef", _settings->_showtime, m_timerResults);
|
||||||
|
simplifyTypedef();
|
||||||
|
} else {
|
||||||
|
simplifyTypedef();
|
||||||
|
}
|
||||||
|
|
||||||
// catch bad typedef canonicalization
|
// catch bad typedef canonicalization
|
||||||
//
|
//
|
||||||
|
@ -2298,7 +2306,12 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
simplifyVarDecl(false);
|
simplifyVarDecl(false);
|
||||||
|
|
||||||
if (!preprocessorCondition) {
|
if (!preprocessorCondition) {
|
||||||
setVarId();
|
if (m_timerResults) {
|
||||||
|
Timer t("Tokenizer::tokenize::setVarId", _settings->_showtime, m_timerResults);
|
||||||
|
setVarId();
|
||||||
|
} else {
|
||||||
|
setVarId();
|
||||||
|
}
|
||||||
|
|
||||||
createLinks2();
|
createLinks2();
|
||||||
|
|
||||||
|
@ -3743,7 +3756,12 @@ bool Tokenizer::simplifyTokenList()
|
||||||
simplifyIfAssign(); // could be affected by simplifyIfNot
|
simplifyIfAssign(); // could be affected by simplifyIfNot
|
||||||
|
|
||||||
// In case variable declarations have been updated...
|
// 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;
|
bool modified = true;
|
||||||
while (modified) {
|
while (modified) {
|
||||||
|
|
|
@ -34,6 +34,7 @@ class Token;
|
||||||
class ErrorLogger;
|
class ErrorLogger;
|
||||||
class Settings;
|
class Settings;
|
||||||
class SymbolDatabase;
|
class SymbolDatabase;
|
||||||
|
class TimerResults;
|
||||||
|
|
||||||
/// @addtogroup Core
|
/// @addtogroup Core
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -49,6 +50,10 @@ public:
|
||||||
Tokenizer(const Settings * settings, ErrorLogger *errorLogger);
|
Tokenizer(const Settings * settings, ErrorLogger *errorLogger);
|
||||||
~Tokenizer();
|
~Tokenizer();
|
||||||
|
|
||||||
|
void setTimerResults(TimerResults *tr) {
|
||||||
|
m_timerResults = tr;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the source file path. e.g. "file.cpp" */
|
/** Returns the source file path. e.g. "file.cpp" */
|
||||||
const std::string& getSourceFilePath() const;
|
const std::string& getSourceFilePath() const;
|
||||||
|
|
||||||
|
@ -781,6 +786,11 @@ private:
|
||||||
* removed from the token list
|
* removed from the token list
|
||||||
*/
|
*/
|
||||||
bool _codeWithTemplates;
|
bool _codeWithTemplates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TimerResults
|
||||||
|
*/
|
||||||
|
TimerResults *m_timerResults;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
Loading…
Reference in New Issue