@@ -55,8 +55,6 @@ static constexpr char ATTR_MY_ARGNR[] = "my-argnr";
5555static constexpr char ATTR_MY_ARGNAME[] = " my-argname" ;
5656static constexpr char ATTR_VALUE[] = " value" ;
5757
58- int CTU::maxCtuDepth = 2 ;
59-
6058std::string CTU::getFunctionId (const Tokenizer &tokenizer, const Function *function)
6159{
6260 return tokenizer.list .file (function->tokenDef ) + ' :' + std::to_string (function->tokenDef ->linenr ()) + ' :' + std::to_string (function->tokenDef ->column ());
@@ -502,10 +500,11 @@ static bool findPath(const std::string &callId,
502500 const std::map<std::string, std::list<const CTU::FileInfo::CallBase *>> &callsMap,
503501 const CTU::FileInfo::CallBase *path[10 ],
504502 int index,
505- bool warning)
503+ bool warning,
504+ int maxCtuDepth)
506505{
507- if (index >= CTU:: maxCtuDepth || index >= 10 )
508- return false ;
506+ if (index >= maxCtuDepth)
507+ return false ; // TODO: add bailout message?
509508
510509 const std::map<std::string, std::list<const CTU::FileInfo::CallBase *>>::const_iterator it = callsMap.find (callId);
511510 if (it == callsMap.end ())
@@ -543,7 +542,7 @@ static bool findPath(const std::string &callId,
543542 if (!nestedCall)
544543 continue ;
545544
546- if (findPath (nestedCall->myId , nestedCall->myArgNr , unsafeValue, invalidValue, callsMap, path, index + 1 , warning)) {
545+ if (findPath (nestedCall->myId , nestedCall->myArgNr , unsafeValue, invalidValue, callsMap, path, index + 1 , warning, maxCtuDepth )) {
547546 path[index] = nestedCall;
548547 return true ;
549548 }
@@ -557,13 +556,14 @@ std::list<ErrorMessage::FileLocation> CTU::FileInfo::getErrorPath(InvalidValueTy
557556 const std::map<std::string, std::list<const CTU::FileInfo::CallBase *>> &callsMap,
558557 const char info[],
559558 const FunctionCall ** const functionCallPtr,
560- bool warning)
559+ bool warning,
560+ int maxCtuDepth)
561561{
562562 std::list<ErrorMessage::FileLocation> locationList;
563563
564564 const CTU::FileInfo::CallBase *path[10 ] = {nullptr };
565565
566- if (!findPath (unsafeUsage.myId , unsafeUsage.myArgNr , unsafeUsage.value , invalidValue, callsMap, path, 0 , warning))
566+ if (!findPath (unsafeUsage.myId , unsafeUsage.myArgNr , unsafeUsage.value , invalidValue, callsMap, path, 0 , warning, maxCtuDepth ))
567567 return locationList;
568568
569569 const std::string value1 = (invalidValue == InvalidValueType::null) ? " null" : " uninitialized" ;
0 commit comments