@@ -8501,10 +8501,17 @@ static void valueFlowContainerSetTokValue(TokenList* tokenlist, const Settings*
8501
8501
}
8502
8502
}
8503
8503
8504
+ static const Scope* getFunctionScope (const Scope* scope) {
8505
+ while (scope && scope->type != Scope::ScopeType::eFunction)
8506
+ scope = scope->nestedIn ;
8507
+ return scope;
8508
+ }
8509
+
8504
8510
static void valueFlowContainerSize (TokenList* tokenlist,
8505
8511
SymbolDatabase* symboldatabase,
8506
8512
ErrorLogger* /* errorLogger*/ ,
8507
- const Settings* settings)
8513
+ const Settings* settings,
8514
+ const std::set<const Scope*>& skippedFunctions)
8508
8515
{
8509
8516
// declaration
8510
8517
for (const Variable *var : symboldatabase->variableList ()) {
@@ -8516,6 +8523,8 @@ static void valueFlowContainerSize(TokenList* tokenlist,
8516
8523
continue ;
8517
8524
if (!astIsContainer (var->nameToken ()))
8518
8525
continue ;
8526
+ if (skippedFunctions.count (getFunctionScope (var->scope ())))
8527
+ continue ;
8519
8528
8520
8529
bool known = true ;
8521
8530
int size = 0 ;
@@ -9077,7 +9086,7 @@ void ValueFlow::setValues(TokenList *tokenlist, SymbolDatabase* symboldatabase,
9077
9086
const std::uint64_t stopTime = getValueFlowStopTime (settings);
9078
9087
9079
9088
std::set<const Scope*> skippedFunctions;
9080
- if (settings->performanceValueFlowMaxIfCount < 1000 ) {
9089
+ if (settings->performanceValueFlowMaxIfCount > 0 ) {
9081
9090
for (const Scope* functionScope: symboldatabase->functionScopes ) {
9082
9091
int countIfScopes = 0 ;
9083
9092
std::vector<const Scope*> scopes{functionScope};
@@ -9093,15 +9102,17 @@ void ValueFlow::setValues(TokenList *tokenlist, SymbolDatabase* symboldatabase,
9093
9102
if (countIfScopes > settings->performanceValueFlowMaxIfCount ) {
9094
9103
skippedFunctions.emplace (functionScope);
9095
9104
9096
- const std::string& functionName = functionScope->className ;
9097
- const std::list<ErrorMessage::FileLocation> callstack (1 , ErrorMessage::FileLocation (functionScope->bodyStart , tokenlist));
9098
- const ErrorMessage errmsg (callstack, tokenlist->getSourceFilePath (), Severity::information,
9099
- " ValueFlow analysis is limited in " + functionName + " because if-count in function " +
9100
- std::to_string (countIfScopes) + " exceeds limit " +
9101
- std::to_string (settings->performanceValueFlowMaxIfCount ) + " . The limit can be adjusted with "
9102
- " --performance-valueflow-max-if-count. Increasing the if-count limit will likely increase the "
9103
- " analysis time." , " performanceValueflowMaxIfCountExceeded" , Certainty::normal);
9104
- errorLogger->reportErr (errmsg);
9105
+ if (settings->severity .isEnabled (Severity::information)) {
9106
+ const std::string& functionName = functionScope->className ;
9107
+ const std::list<ErrorMessage::FileLocation> callstack (1 , ErrorMessage::FileLocation (functionScope->bodyStart , tokenlist));
9108
+ const ErrorMessage errmsg (callstack, tokenlist->getSourceFilePath (), Severity::information,
9109
+ " ValueFlow analysis is limited in " + functionName + " because if-count in function " +
9110
+ std::to_string (countIfScopes) + " exceeds limit " +
9111
+ std::to_string (settings->performanceValueFlowMaxIfCount ) + " . The limit can be adjusted with "
9112
+ " --performance-valueflow-max-if-count. Increasing the if-count limit will likely increase the "
9113
+ " analysis time." , " performanceValueflowMaxIfCountExceeded" , Certainty::normal);
9114
+ errorLogger->reportErr (errmsg);
9115
+ }
9105
9116
}
9106
9117
}
9107
9118
}
@@ -9159,8 +9170,8 @@ void ValueFlow::setValues(TokenList *tokenlist, SymbolDatabase* symboldatabase,
9159
9170
valueFlowCondition (IteratorConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions);
9160
9171
if (std::time (nullptr ) < stopTime)
9161
9172
valueFlowIteratorInfer (tokenlist, settings);
9162
- if (std::time (nullptr ) < stopTime && skippedFunctions. empty () )
9163
- valueFlowContainerSize (tokenlist, symboldatabase, errorLogger, settings);
9173
+ if (std::time (nullptr ) < stopTime)
9174
+ valueFlowContainerSize (tokenlist, symboldatabase, errorLogger, settings, skippedFunctions );
9164
9175
if (std::time (nullptr ) < stopTime)
9165
9176
valueFlowCondition (ContainerConditionHandler{}, tokenlist, symboldatabase, errorLogger, settings, skippedFunctions);
9166
9177
}
0 commit comments