@@ -1073,7 +1073,7 @@ bool isAliasOf(const Token* tok, const Token* expr, nonneg int* indirect)
10731073 const Token* r = nullptr ;
10741074 if (indirect)
10751075 *indirect = 1 ;
1076- for (const ReferenceToken& ref : followAllReferences ( tok)) {
1076+ for (const ReferenceToken& ref : tok-> refs ( )) {
10771077 const bool pointer = astIsPointer (ref.token );
10781078 r = findAstNode (expr, [&](const Token* childTok) {
10791079 if (childTok->exprId () == 0 )
@@ -1252,11 +1252,11 @@ static void followVariableExpressionError(const Token *tok1, const Token *tok2,
12521252 errors->push_back (std::move (item));
12531253}
12541254
1255- SmallVector<ReferenceToken> followAllReferences (const Token* tok,
1256- bool temporary,
1257- bool inconclusive,
1258- ErrorPath errors,
1259- int depth)
1255+ static SmallVector<ReferenceToken> followAllReferencesInternal (const Token* tok,
1256+ bool temporary = true ,
1257+ bool inconclusive = true ,
1258+ ErrorPath errors = ErrorPath{} ,
1259+ int depth = 20 )
12601260{
12611261 struct ReferenceTokenLess {
12621262 bool operator ()(const ReferenceToken& x, const ReferenceToken& y) const {
@@ -1302,16 +1302,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13021302 return refs_result;
13031303 }
13041304 if (vartok)
1305- return followAllReferences (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
1305+ return followAllReferencesInternal (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
13061306 }
13071307 }
13081308 } else if (Token::simpleMatch (tok, " ?" ) && Token::simpleMatch (tok->astOperand2 (), " :" )) {
13091309 std::set<ReferenceToken, ReferenceTokenLess> result;
13101310 const Token* tok2 = tok->astOperand2 ();
13111311
1312- auto refs = followAllReferences (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
1312+ auto refs = followAllReferencesInternal (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
13131313 result.insert (refs.cbegin (), refs.cend ());
1314- refs = followAllReferences (tok2->astOperand2 (), temporary, inconclusive, errors, depth - 1 );
1314+ refs = followAllReferencesInternal (tok2->astOperand2 (), temporary, inconclusive, errors, depth - 1 );
13151315 result.insert (refs.cbegin (), refs.cend ());
13161316
13171317 if (!inconclusive && result.size () != 1 ) {
@@ -1339,7 +1339,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13391339 if (returnTok == tok)
13401340 continue ;
13411341 for (const ReferenceToken& rt :
1342- followAllReferences (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
1342+ followAllReferencesInternal (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
13431343 const Variable* argvar = rt.token ->variable ();
13441344 if (!argvar) {
13451345 SmallVector<ReferenceToken> refs_result;
@@ -1364,7 +1364,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13641364 er.emplace_back (returnTok, " Return reference." );
13651365 er.emplace_back (tok->previous (), " Called function passing '" + argTok->expressionString () + " '." );
13661366 auto refs =
1367- followAllReferences (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
1367+ followAllReferencesInternal (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
13681368 result.insert (refs.cbegin (), refs.cend ());
13691369 if (!inconclusive && result.size () > 1 ) {
13701370 SmallVector<ReferenceToken> refs_result;
@@ -1385,11 +1385,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13851385 return refs_result;
13861386}
13871387
1388+ SmallVector<ReferenceToken> followAllReferences (const Token* tok, bool temporary)
1389+ {
1390+ return followAllReferencesInternal (tok, temporary);
1391+ }
1392+
13881393const Token* followReferences (const Token* tok, ErrorPath* errors)
13891394{
13901395 if (!tok)
13911396 return nullptr ;
1392- auto refs = followAllReferences (tok, true , false );
1397+ auto refs = followAllReferencesInternal (tok, true , false );
13931398 if (refs.size () == 1 ) {
13941399 if (errors)
13951400 *errors = std::move (refs.front ().errors );
0 commit comments