@@ -69,8 +69,10 @@ const Token* findExpression(const nonneg int exprid,
6969static int findArgumentPosRecursive (const Token* tok, const Token* tokToFind, bool &found, nonneg int depth=0 )
7070{
7171 ++depth;
72- if (!tok || depth >= 100 )
72+ if (!tok || depth >= 100 ) {
73+ // TODO: add bailout message
7374 return -1 ;
75+ }
7476 if (tok->str () == " ," ) {
7577 int res = findArgumentPosRecursive (tok->astOperand1 (), tokToFind, found, depth);
7678 if (res == -1 )
@@ -112,8 +114,10 @@ template<class T, class OuputIterator, REQUIRES("T must be a Token class", std::
112114static void astFlattenCopy (T* tok, const char * op, OuputIterator out, nonneg int depth = 100 )
113115{
114116 --depth;
115- if (!tok || depth < 0 )
117+ if (!tok || depth < 0 ) {
118+ // TODO: add bailout message
116119 return ;
120+ }
117121 if (strcmp (tok->str ().c_str (), op) == 0 ) {
118122 astFlattenCopy (tok->astOperand1 (), op, out, depth);
119123 astFlattenCopy (tok->astOperand2 (), op, out, depth);
@@ -140,8 +144,10 @@ std::vector<Token*> astFlatten(Token* tok, const char* op)
140144nonneg int astCount (const Token* tok, const char * op, int depth)
141145{
142146 --depth;
143- if (!tok || depth < 0 )
147+ if (!tok || depth < 0 ) {
148+ // TODO: add bailout message
144149 return 0 ;
150+ }
145151 if (strcmp (tok->str ().c_str (), op) == 0 )
146152 return astCount (tok->astOperand1 (), op, depth) + astCount (tok->astOperand2 (), op, depth);
147153 return 1 ;
@@ -1119,6 +1125,7 @@ bool exprDependsOnThis(const Token* expr, bool onVar, nonneg int depth)
11191125 return true ;
11201126 if (depth >= 1000 )
11211127 // Abort recursion to avoid stack overflow
1128+ // TODO: add bailout message
11221129 return true ;
11231130 ++depth;
11241131
@@ -1256,6 +1263,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
12561263 if (!tok)
12571264 return {};
12581265 if (depth < 0 ) {
1266+ // TODO: add bailout message
12591267 SmallVector<ReferenceToken> refs_result;
12601268 refs_result.emplace_back (tok, std::move (errors));
12611269 return refs_result;
@@ -2855,8 +2863,10 @@ static bool isExpressionChangedAt(const F& getExprTok,
28552863 const Settings& settings,
28562864 int depth)
28572865{
2858- if (depth < 0 )
2866+ if (depth < 0 ) {
2867+ // TODO: add bailout message
28592868 return true ;
2869+ }
28602870 if (!isMutableExpression (tok))
28612871 return false ;
28622872 if (tok->exprId () != exprid || (!tok->varId () && !tok->isName ())) {
@@ -2906,8 +2916,10 @@ Token* findVariableChanged(Token *start, const Token *end, int indirect, const n
29062916{
29072917 if (!precedes (start, end))
29082918 return nullptr ;
2909- if (depth < 0 )
2919+ if (depth < 0 ) {
2920+ // TODO: add bailout message
29102921 return start;
2922+ }
29112923 auto getExprTok = memoize ([&] {
29122924 return findExpression (start, exprid);
29132925 });
@@ -3005,8 +3017,10 @@ static const Token* findExpressionChangedImpl(const Token* expr,
30053017 int depth,
30063018 Find find)
30073019{
3008- if (depth < 0 )
3020+ if (depth < 0 ) {
3021+ // TODO: add bailout message
30093022 return start;
3023+ }
30103024 if (!precedes (start, end))
30113025 return nullptr ;
30123026 const Token* result = nullptr ;
0 commit comments