@@ -1064,7 +1064,7 @@ bool isAliasOf(const Token* tok, const Token* expr, int* indirect)
10641064 const Token* r = nullptr ;
10651065 if (indirect)
10661066 *indirect = 1 ;
1067- for (const ReferenceToken& ref : followAllReferences ( tok)) {
1067+ for (const ReferenceToken& ref : tok-> refs ( )) {
10681068 const bool pointer = astIsPointer (ref.token );
10691069 r = findAstNode (expr, [&](const Token* childTok) {
10701070 if (childTok->exprId () == 0 )
@@ -1242,11 +1242,11 @@ static void followVariableExpressionError(const Token *tok1, const Token *tok2,
12421242 errors->push_back (std::move (item));
12431243}
12441244
1245- SmallVector<ReferenceToken> followAllReferences (const Token* tok,
1246- bool temporary,
1247- bool inconclusive,
1248- ErrorPath errors,
1249- int depth)
1245+ static SmallVector<ReferenceToken> followAllReferencesInternal (const Token* tok,
1246+ bool temporary = true ,
1247+ bool inconclusive = true ,
1248+ ErrorPath errors = ErrorPath{} ,
1249+ int depth = 20 )
12501250{
12511251 struct ReferenceTokenLess {
12521252 bool operator ()(const ReferenceToken& x, const ReferenceToken& y) const {
@@ -1292,16 +1292,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
12921292 return refs_result;
12931293 }
12941294 if (vartok)
1295- return followAllReferences (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
1295+ return followAllReferencesInternal (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
12961296 }
12971297 }
12981298 } else if (Token::simpleMatch (tok, " ?" ) && Token::simpleMatch (tok->astOperand2 (), " :" )) {
12991299 std::set<ReferenceToken, ReferenceTokenLess> result;
13001300 const Token* tok2 = tok->astOperand2 ();
13011301
1302- auto refs = followAllReferences (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
1302+ auto refs = followAllReferencesInternal (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
13031303 result.insert (refs.cbegin (), refs.cend ());
1304- refs = followAllReferences (tok2->astOperand2 (), temporary, inconclusive, errors, depth - 1 );
1304+ refs = followAllReferencesInternal (tok2->astOperand2 (), temporary, inconclusive, errors, depth - 1 );
13051305 result.insert (refs.cbegin (), refs.cend ());
13061306
13071307 if (!inconclusive && result.size () != 1 ) {
@@ -1329,7 +1329,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13291329 if (returnTok == tok)
13301330 continue ;
13311331 for (const ReferenceToken& rt :
1332- followAllReferences (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
1332+ followAllReferencesInternal (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
13331333 const Variable* argvar = rt.token ->variable ();
13341334 if (!argvar) {
13351335 SmallVector<ReferenceToken> refs_result;
@@ -1354,7 +1354,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13541354 er.emplace_back (returnTok, " Return reference." );
13551355 er.emplace_back (tok->previous (), " Called function passing '" + argTok->expressionString () + " '." );
13561356 auto refs =
1357- followAllReferences (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
1357+ followAllReferencesInternal (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
13581358 result.insert (refs.cbegin (), refs.cend ());
13591359 if (!inconclusive && result.size () > 1 ) {
13601360 SmallVector<ReferenceToken> refs_result;
@@ -1375,11 +1375,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13751375 return refs_result;
13761376}
13771377
1378+ SmallVector<ReferenceToken> followAllReferences (const Token* tok, bool temporary)
1379+ {
1380+ return followAllReferencesInternal (tok, temporary);
1381+ }
1382+
13781383const Token* followReferences (const Token* tok, ErrorPath* errors)
13791384{
13801385 if (!tok)
13811386 return nullptr ;
1382- auto refs = followAllReferences (tok, true , false );
1387+ auto refs = followAllReferencesInternal (tok, true , false );
13831388 if (refs.size () == 1 ) {
13841389 if (errors)
13851390 *errors = std::move (refs.front ().errors );
0 commit comments