@@ -1066,7 +1066,7 @@ bool isAliasOf(const Token* tok, const Token* expr, int* indirect)
10661066 const Token* r = nullptr ;
10671067 if (indirect)
10681068 *indirect = 1 ;
1069- for (const ReferenceToken& ref : followAllReferences ( tok)) {
1069+ for (const ReferenceToken& ref : tok-> refs ( )) {
10701070 const bool pointer = astIsPointer (ref.token );
10711071 r = findAstNode (expr, [&](const Token* childTok) {
10721072 if (childTok->exprId () == 0 )
@@ -1244,11 +1244,11 @@ static void followVariableExpressionError(const Token *tok1, const Token *tok2,
12441244 errors->push_back (std::move (item));
12451245}
12461246
1247- SmallVector<ReferenceToken> followAllReferences (const Token* tok,
1248- bool temporary,
1249- bool inconclusive,
1250- ErrorPath errors,
1251- int depth)
1247+ static SmallVector<ReferenceToken> followAllReferencesInternal (const Token* tok,
1248+ bool temporary = true ,
1249+ bool inconclusive = true ,
1250+ ErrorPath errors = ErrorPath{} ,
1251+ int depth = 20 )
12521252{
12531253 struct ReferenceTokenLess {
12541254 bool operator ()(const ReferenceToken& x, const ReferenceToken& y) const {
@@ -1294,16 +1294,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
12941294 return refs_result;
12951295 }
12961296 if (vartok)
1297- return followAllReferences (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
1297+ return followAllReferencesInternal (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
12981298 }
12991299 }
13001300 } else if (Token::simpleMatch (tok, " ?" ) && Token::simpleMatch (tok->astOperand2 (), " :" )) {
13011301 std::set<ReferenceToken, ReferenceTokenLess> result;
13021302 const Token* tok2 = tok->astOperand2 ();
13031303
1304- auto refs = followAllReferences (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
1304+ auto refs = followAllReferencesInternal (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
13051305 result.insert (refs.cbegin (), refs.cend ());
1306- refs = followAllReferences (tok2->astOperand2 (), temporary, inconclusive, errors, depth - 1 );
1306+ refs = followAllReferencesInternal (tok2->astOperand2 (), temporary, inconclusive, errors, depth - 1 );
13071307 result.insert (refs.cbegin (), refs.cend ());
13081308
13091309 if (!inconclusive && result.size () != 1 ) {
@@ -1331,7 +1331,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13311331 if (returnTok == tok)
13321332 continue ;
13331333 for (const ReferenceToken& rt :
1334- followAllReferences (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
1334+ followAllReferencesInternal (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
13351335 const Variable* argvar = rt.token ->variable ();
13361336 if (!argvar) {
13371337 SmallVector<ReferenceToken> refs_result;
@@ -1356,7 +1356,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13561356 er.emplace_back (returnTok, " Return reference." );
13571357 er.emplace_back (tok->previous (), " Called function passing '" + argTok->expressionString () + " '." );
13581358 auto refs =
1359- followAllReferences (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
1359+ followAllReferencesInternal (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
13601360 result.insert (refs.cbegin (), refs.cend ());
13611361 if (!inconclusive && result.size () > 1 ) {
13621362 SmallVector<ReferenceToken> refs_result;
@@ -1377,11 +1377,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13771377 return refs_result;
13781378}
13791379
1380+ SmallVector<ReferenceToken> followAllReferences (const Token* tok, bool temporary)
1381+ {
1382+ return followAllReferencesInternal (tok, temporary);
1383+ }
1384+
13801385const Token* followReferences (const Token* tok, ErrorPath* errors)
13811386{
13821387 if (!tok)
13831388 return nullptr ;
1384- auto refs = followAllReferences (tok, true , false );
1389+ auto refs = followAllReferencesInternal (tok, true , false );
13851390 if (refs.size () == 1 ) {
13861391 if (errors)
13871392 *errors = std::move (refs.front ().errors );
0 commit comments