@@ -2428,6 +2428,10 @@ static std::string execute(const Token *start, const Token *end, Data &data)
24282428 };
24292429 Recursion updateRecursion (&data.recursion , data.recursion );
24302430
2431+ const std::time_t stopTime = (data.settings ->bugHuntingCheckFunctionMaxTime > 0 ) ?
2432+ (data.startTime + data.settings ->bugHuntingCheckFunctionMaxTime ) :
2433+ ~0ULL ;
2434+
24312435 for (const Token *tok = start; tok != end; tok = tok->next ()) {
24322436 if (Token::Match (tok, " [;{}]" )) {
24332437 data.trackProgramState (tok);
@@ -2438,6 +2442,8 @@ static std::string execute(const Token *start, const Token *end, Data &data)
24382442 if (Token::Match (prev, " [;{}] return|throw" ))
24392443 return data.str ();
24402444 }
2445+ if (std::time (nullptr ) > stopTime)
2446+ return " " ;
24412447 }
24422448
24432449 if (Token::simpleMatch (tok, " __CPPCHECK_BAILOUT__ ;" ))
@@ -2850,6 +2856,10 @@ void ExprEngine::executeFunction(const Scope *functionScope, ErrorLogger *errorL
28502856
28512857 data.contractConstraints (function, executeExpression1);
28522858
2859+ const std::time_t stopTime = (data.settings ->bugHuntingCheckFunctionMaxTime > 0 ) ?
2860+ (data.startTime + data.settings ->bugHuntingCheckFunctionMaxTime ) :
2861+ ~0ULL ;
2862+
28532863 try {
28542864 execute (functionScope->bodyStart , functionScope->bodyEnd , data);
28552865 } catch (const ExprEngineException &e) {
@@ -2858,6 +2868,8 @@ void ExprEngine::executeFunction(const Scope *functionScope, ErrorLogger *errorL
28582868 trackExecution.setAbortLine (e.tok ->linenr ());
28592869 auto bailoutValue = std::make_shared<BailoutValue>();
28602870 for (const Token *tok = e.tok ; tok != functionScope->bodyEnd ; tok = tok->next ()) {
2871+ if (std::time (nullptr ) >= stopTime)
2872+ break ;
28612873 if (Token::Match (tok, " return|throw|while|if|for (" )) {
28622874 tok = tok->next ();
28632875 continue ;
0 commit comments