Use MAXTIME in templatesimplifier

This commit is contained in:
Daniel Marjamäki 2016-02-12 12:05:32 +01:00
parent 087b233ffd
commit 6c324013e7
3 changed files with 19 additions and 0 deletions

View File

@ -1222,6 +1222,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
ErrorLogger* errorlogger, ErrorLogger* errorlogger,
const Settings *_settings, const Settings *_settings,
const Token *tok, const Token *tok,
const std::time_t maxtime,
std::list<Token *> &templateInstantiations, std::list<Token *> &templateInstantiations,
std::set<std::string> &expandedtemplates) std::set<std::string> &expandedtemplates)
{ {
@ -1274,6 +1275,12 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
Token * const tok2 = *iter2; Token * const tok2 = *iter2;
if (errorlogger && !tokenlist.getFiles().empty()) if (errorlogger && !tokenlist.getFiles().empty())
errorlogger->reportProgress(tokenlist.getFiles()[0], "TemplateSimplifier::simplifyTemplateInstantiations()", tok2->progressValue()); errorlogger->reportProgress(tokenlist.getFiles()[0], "TemplateSimplifier::simplifyTemplateInstantiations()", tok2->progressValue());
#ifdef MAXTIME
if (std::time(0) > maxtime)
return false;
#else
(void)maxtime;
#endif
assert(tokenlist.validateToken(tok2)); // that assertion fails on examples from #6021 assert(tokenlist.validateToken(tok2)); // that assertion fails on examples from #6021
if (tok2->str() != name) if (tok2->str() != name)
continue; continue;
@ -1404,6 +1411,7 @@ void TemplateSimplifier::simplifyTemplates(
TokenList& tokenlist, TokenList& tokenlist,
ErrorLogger* errorlogger, ErrorLogger* errorlogger,
const Settings *_settings, const Settings *_settings,
const std::time_t maxtime,
bool &_codeWithTemplates bool &_codeWithTemplates
) )
{ {
@ -1450,6 +1458,7 @@ void TemplateSimplifier::simplifyTemplates(
errorlogger, errorlogger,
_settings, _settings,
*iter1, *iter1,
maxtime,
templateInstantiations, templateInstantiations,
expandedtemplates); expandedtemplates);
if (instantiated) if (instantiated)

View File

@ -25,6 +25,7 @@
#include <set> #include <set>
#include <list> #include <list>
#include <string> #include <string>
#include <ctime>
#include <vector> #include <vector>
#include "config.h" #include "config.h"
@ -137,6 +138,7 @@ public:
* @param errorlogger error logger * @param errorlogger error logger
* @param _settings settings * @param _settings settings
* @param tok token where the template declaration begins * @param tok token where the template declaration begins
* @param maxtime time when the simplification will stop
* @param templateInstantiations a list of template usages (not necessarily just for this template) * @param templateInstantiations a list of template usages (not necessarily just for this template)
* @param expandedtemplates all templates that has been expanded so far. The full names are stored. * @param expandedtemplates all templates that has been expanded so far. The full names are stored.
* @return true if the template was instantiated * @return true if the template was instantiated
@ -146,6 +148,7 @@ public:
ErrorLogger* errorlogger, ErrorLogger* errorlogger,
const Settings *_settings, const Settings *_settings,
const Token *tok, const Token *tok,
const std::time_t maxtime,
std::list<Token *> &templateInstantiations, std::list<Token *> &templateInstantiations,
std::set<std::string> &expandedtemplates); std::set<std::string> &expandedtemplates);
@ -154,12 +157,14 @@ public:
* @param tokenlist token list * @param tokenlist token list
* @param errorlogger error logger * @param errorlogger error logger
* @param _settings settings * @param _settings settings
* @param maxtime time when the simplification should be stopped
* @param _codeWithTemplates output parameter that is set if code contains templates * @param _codeWithTemplates output parameter that is set if code contains templates
*/ */
static void simplifyTemplates( static void simplifyTemplates(
TokenList& tokenlist, TokenList& tokenlist,
ErrorLogger* errorlogger, ErrorLogger* errorlogger,
const Settings *_settings, const Settings *_settings,
const std::time_t maxtime,
bool &_codeWithTemplates); bool &_codeWithTemplates);
/** /**

View File

@ -2357,6 +2357,11 @@ void Tokenizer::simplifyTemplates()
list, list,
_errorLogger, _errorLogger,
_settings, _settings,
#ifdef MAXTIME
maxtime,
#else
0, // ignored
#endif
_codeWithTemplates); _codeWithTemplates);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------