@@ -1161,8 +1161,10 @@ static size_t bitCeil(size_t x)
11611161
11621162static size_t getAlignOf (const ValueType& vt, const Settings& settings, int maxRecursion = 0 )
11631163{
1164- if (maxRecursion == 100 )
1164+ if (maxRecursion == settings.vfOptions .maxAlignOfRecursion ) {
1165+ // TODO: add bailout message
11651166 return 0 ;
1167+ }
11661168 if (vt.pointer || vt.reference != Reference::None || vt.isPrimitive ()) {
11671169 auto align = ValueFlow::getSizeOf (vt, settings);
11681170 return align == 0 ? 0 : bitCeil (align);
@@ -1196,8 +1198,10 @@ static nonneg int getSizeOfType(const Token *typeTok, const Settings &settings)
11961198
11971199size_t ValueFlow::getSizeOf (const ValueType &vt, const Settings &settings, int maxRecursion)
11981200{
1199- if (maxRecursion == 100 )
1201+ if (maxRecursion == settings.vfOptions .maxSizeOfRecursion ) {
1202+ // TODO: add bailout message
12001203 return 0 ;
1204+ }
12011205 if (vt.pointer || vt.reference != Reference::None)
12021206 return settings.platform .sizeof_pointer ;
12031207 if (vt.type == ValueType::Type::BOOL || vt.type == ValueType::Type::CHAR)
@@ -3294,9 +3298,10 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
32943298 }
32953299
32963300 void setupExprVarIds (const Token* start, int depth = 0 ) {
3297- constexpr int maxDepth = 4 ;
3298- if (depth > maxDepth)
3301+ if (depth > settings. vfOptions . maxExprVarIdDepth ) {
3302+ // TODO: add bailout message
32993303 return ;
3304+ }
33003305 visitAstNodes (start, [&](const Token* tok) {
33013306 const bool top = depth == 0 && tok == start;
33023307 const bool ispointer = astIsPointer (tok) || astIsSmartPointer (tok) || astIsIterator (tok);
@@ -5399,7 +5404,7 @@ static const Scope* getLoopScope(const Token* tok)
53995404//
54005405static void valueFlowConditionExpressions (const TokenList &tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger &errorLogger, const Settings &settings)
54015406{
5402- if (!settings.daca && ( settings.checkLevel == Settings::CheckLevel::normal) )
5407+ if (!settings.daca && ! settings.vfOptions . doConditionExpressionAnalysis )
54035408 {
54045409 if (settings.debugwarnings ) {
54055410 ErrorMessage::FileLocation loc (tokenlist.getSourceFilePath (), 0 , 0 );
@@ -5416,7 +5421,7 @@ static void valueFlowConditionExpressions(const TokenList &tokenlist, const Symb
54165421 continue ;
54175422 }
54185423
5419- if (settings.daca && ( settings.checkLevel == Settings::CheckLevel::normal) )
5424+ if (settings.daca && ! settings.vfOptions . doConditionExpressionAnalysis )
54205425 continue ;
54215426
54225427 for (Token* tok = const_cast <Token*>(scope->bodyStart ); tok != scope->bodyEnd ; tok = tok->next ()) {
@@ -7195,13 +7200,14 @@ static bool valueFlowForLoop2(const Token *tok,
71957200 ProgramMemory startMemory (programMemory);
71967201 ProgramMemory endMemory;
71977202
7198- int maxcount = 10000 ;
7203+ int maxcount = settings. vfOptions . maxForLoopCount ;
71997204 while (result != 0 && !error && --maxcount > 0 ) {
72007205 endMemory = programMemory;
72017206 execute (thirdExpression, programMemory, &result, &error, settings);
72027207 if (!error)
72037208 execute (secondExpression, programMemory, &result, &error, settings);
72047209 }
7210+ // TODO: add bailout message
72057211
72067212 if (memory1)
72077213 memory1->swap (startMemory);
@@ -7580,7 +7586,7 @@ static bool productParams(const Settings& settings, const std::unordered_map<Key
75807586 args.back ()[p.first ] = p.second .front ();
75817587 }
75827588 bool bail = false ;
7583- int max = settings.performanceValueFlowMaxSubFunctionArgs ;
7589+ int max = settings.vfOptions . maxSubFunctionArgs ;
75847590 for (const auto & p:vars) {
75857591 if (args.size () > max) {
75867592 bail = true ;
@@ -7611,6 +7617,7 @@ static bool productParams(const Settings& settings, const std::unordered_map<Key
76117617 if (args.size () > max) {
76127618 bail = true ;
76137619 args.resize (max);
7620+ // TODO: add bailout message
76147621 }
76157622
76167623 for (const auto & arg:args) {
@@ -9474,7 +9481,7 @@ struct ValueFlowPassRunner {
94749481 bool run (std::initializer_list<ValuePtr<ValueFlowPass>> passes) const
94759482 {
94769483 std::size_t values = 0 ;
9477- std::size_t n = state.settings .valueFlowMaxIterations ;
9484+ std::size_t n = state.settings .vfOptions . maxIterations ;
94789485 while (n > 0 && values != getTotalValues ()) {
94799486 values = getTotalValues ();
94809487 if (std::any_of (passes.begin (), passes.end (), [&](const ValuePtr<ValueFlowPass>& pass) {
@@ -9501,8 +9508,10 @@ struct ValueFlowPassRunner {
95019508 bool run (const ValuePtr<ValueFlowPass>& pass) const
95029509 {
95039510 auto start = Clock::now ();
9504- if (start > stop)
9511+ if (start > stop) {
9512+ // TODO: add bailout message
95059513 return true ;
9514+ }
95069515 if (!state.tokenlist .isCPP () && pass->cpp ())
95079516 return false ;
95089517 if (timerResults) {
@@ -9524,7 +9533,7 @@ struct ValueFlowPassRunner {
95249533
95259534 void setSkippedFunctions ()
95269535 {
9527- if (state.settings .performanceValueFlowMaxIfCount > 0 ) {
9536+ if (state.settings .vfOptions . maxIfCount > 0 ) {
95289537 for (const Scope* functionScope : state.symboldatabase .functionScopes ) {
95299538 int countIfScopes = 0 ;
95309539 std::vector<const Scope*> scopes{functionScope};
@@ -9537,7 +9546,7 @@ struct ValueFlowPassRunner {
95379546 ++countIfScopes;
95389547 }
95399548 }
9540- if (countIfScopes > state.settings .performanceValueFlowMaxIfCount ) {
9549+ if (countIfScopes > state.settings .vfOptions . maxIfCount ) {
95419550 state.skippedFunctions .emplace (functionScope);
95429551
95439552 if (state.settings .severity .isEnabled (Severity::information)) {
@@ -9550,7 +9559,7 @@ struct ValueFlowPassRunner {
95509559 Severity::information,
95519560 " Limiting ValueFlow analysis in function '" + functionName + " ' since it is too complex. "
95529561 " Please specify --check-level=exhaustive to perform full analysis." ,
9553- " checkLevelNormal" ,
9562+ " checkLevelNormal" , // TODO: use more specific ID
95549563 Certainty::normal);
95559564 state.errorLogger .reportErr (errmsg);
95569565 }
@@ -9561,8 +9570,8 @@ struct ValueFlowPassRunner {
95619570
95629571 void setStopTime ()
95639572 {
9564- if (state.settings .performanceValueFlowMaxTime >= 0 )
9565- stop = Clock::now () + std::chrono::seconds{state.settings .performanceValueFlowMaxTime };
9573+ if (state.settings .vfOptions . maxTime >= 0 )
9574+ stop = Clock::now () + std::chrono::seconds{state.settings .vfOptions . maxTime };
95669575 }
95679576
95689577 ValueFlowState state;
0 commit comments