Use fixed number of iterations for valueflow loop (#2205)

This commit is contained in:
Paul Fultz II 2019-09-23 12:35:39 -05:00 committed by Daniel Marjamäki
parent 9025b47f82
commit 1616282f6b
1 changed files with 3 additions and 3 deletions

View File

@ -6302,10 +6302,9 @@ void ValueFlow::setValues(TokenList *tokenlist, SymbolDatabase* symboldatabase,
valueFlowSameExpressions(tokenlist); valueFlowSameExpressions(tokenlist);
valueFlowFwdAnalysis(tokenlist, settings); valueFlowFwdAnalysis(tokenlist, settings);
// Temporary hack.. run valueflow until there is nothing to update or timeout expires
const std::time_t timeout = std::time(nullptr) + TIMEOUT;
std::size_t values = 0; std::size_t values = 0;
while (std::time(nullptr) < timeout && values < getTotalValues(tokenlist)) { std::size_t n = 4;
while (n > 0 && values < getTotalValues(tokenlist)) {
values = getTotalValues(tokenlist); values = getTotalValues(tokenlist);
valueFlowPointerAliasDeref(tokenlist); valueFlowPointerAliasDeref(tokenlist);
valueFlowArrayBool(tokenlist); valueFlowArrayBool(tokenlist);
@ -6328,6 +6327,7 @@ void ValueFlow::setValues(TokenList *tokenlist, SymbolDatabase* symboldatabase,
valueFlowContainerAfterCondition(tokenlist, symboldatabase, errorLogger, settings); valueFlowContainerAfterCondition(tokenlist, symboldatabase, errorLogger, settings);
} }
valueFlowSafeFunctions(tokenlist, symboldatabase, errorLogger, settings); valueFlowSafeFunctions(tokenlist, symboldatabase, errorLogger, settings);
n--;
} }
valueFlowDynamicBufferSize(tokenlist, symboldatabase, errorLogger, settings); valueFlowDynamicBufferSize(tokenlist, symboldatabase, errorLogger, settings);