@@ -107,31 +107,17 @@ static int getArgumentPos(const Token* ftok, const Token* tokToFind){
107107 return findArgumentPos (startTok, tokToFind);
108108}
109109
110- template <class T , REQUIRES(" T must be a Token class" , std::is_convertible<T*, const Token*> )>
111- static void astFlattenRecursive (T* tok, std::vector<T*>& result, const char * op, nonneg int depth = 0 )
112- {
113- ++depth;
114- if (!tok || depth >= 100 )
115- return ;
116- if (tok->str () == op) {
117- astFlattenRecursive (tok->astOperand1 (), result, op, depth);
118- astFlattenRecursive (tok->astOperand2 (), result, op, depth);
119- } else {
120- result.push_back (tok);
121- }
122- }
123-
124110std::vector<const Token*> astFlatten (const Token* tok, const char * op)
125111{
126112 std::vector<const Token*> result;
127- astFlattenRecursive (tok, result, op );
113+ astFlattenCopy (tok, op, std::back_inserter (result) );
128114 return result;
129115}
130116
131117std::vector<Token*> astFlatten (Token* tok, const char * op)
132118{
133119 std::vector<Token*> result;
134- astFlattenRecursive (tok, result, op );
120+ astFlattenCopy (tok, op, std::back_inserter (result) );
135121 return result;
136122}
137123
@@ -163,6 +149,15 @@ bool astHasVar(const Token * tok, nonneg int varid)
163149 return astHasVar (tok->astOperand1 (), varid) || astHasVar (tok->astOperand2 (), varid);
164150}
165151
152+ bool astHasExpr (const Token* tok, nonneg int exprid)
153+ {
154+ if (!tok)
155+ return false ;
156+ if (tok->exprId () == exprid)
157+ return true ;
158+ return astHasExpr (tok->astOperand1 (), exprid) || astHasExpr (tok->astOperand2 (), exprid);
159+ }
160+
166161static bool astIsCharWithSign (const Token *tok, ValueType::Sign sign)
167162{
168163 if (!tok)
0 commit comments