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,
const Settings *_settings,
const Token *tok,
const std::time_t maxtime,
std::list<Token *> &templateInstantiations,
std::set<std::string> &expandedtemplates)
{
@ -1274,6 +1275,12 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
Token * const tok2 = *iter2;
if (errorlogger && !tokenlist.getFiles().empty())
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
if (tok2->str() != name)
continue;
@ -1404,6 +1411,7 @@ void TemplateSimplifier::simplifyTemplates(
TokenList& tokenlist,
ErrorLogger* errorlogger,
const Settings *_settings,
const std::time_t maxtime,
bool &_codeWithTemplates
)
{
@ -1450,6 +1458,7 @@ void TemplateSimplifier::simplifyTemplates(
errorlogger,
_settings,
*iter1,
maxtime,
templateInstantiations,
expandedtemplates);
if (instantiated)

View File

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

View File

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