@@ -1072,7 +1072,7 @@ bool isAliasOf(const Token* tok, const Token* expr, nonneg int* indirect)
10721072 const Token* r = nullptr ;
10731073 if (indirect)
10741074 *indirect = 1 ;
1075- for (const ReferenceToken& ref : followAllReferences ( tok)) {
1075+ for (const ReferenceToken& ref : tok-> refs ( )) {
10761076 const bool pointer = astIsPointer (ref.token );
10771077 r = findAstNode (expr, [&](const Token* childTok) {
10781078 if (childTok->exprId () == 0 )
@@ -1253,11 +1253,11 @@ static void followVariableExpressionError(const Token *tok1, const Token *tok2,
12531253 errors->push_back (std::move (item));
12541254}
12551255
1256- SmallVector<ReferenceToken> followAllReferences (const Token* tok,
1257- bool temporary,
1258- bool inconclusive,
1259- ErrorPath errors,
1260- int depth)
1256+ static SmallVector<ReferenceToken> followAllReferencesInternal (const Token* tok,
1257+ bool temporary = true ,
1258+ bool inconclusive = true ,
1259+ ErrorPath errors = ErrorPath{} ,
1260+ int depth = 20 )
12611261{
12621262 struct ReferenceTokenLess {
12631263 bool operator ()(const ReferenceToken& x, const ReferenceToken& y) const {
@@ -1303,16 +1303,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13031303 return refs_result;
13041304 }
13051305 if (vartok)
1306- return followAllReferences (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
1306+ return followAllReferencesInternal (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
13071307 }
13081308 }
13091309 } else if (Token::simpleMatch (tok, " ?" ) && Token::simpleMatch (tok->astOperand2 (), " :" )) {
13101310 std::set<ReferenceToken, ReferenceTokenLess> result;
13111311 const Token* tok2 = tok->astOperand2 ();
13121312
1313- auto refs = followAllReferences (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
1313+ auto refs = followAllReferencesInternal (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
13141314 result.insert (refs.cbegin (), refs.cend ());
1315- refs = followAllReferences (tok2->astOperand2 (), temporary, inconclusive, errors, depth - 1 );
1315+ refs = followAllReferencesInternal (tok2->astOperand2 (), temporary, inconclusive, errors, depth - 1 );
13161316 result.insert (refs.cbegin (), refs.cend ());
13171317
13181318 if (!inconclusive && result.size () != 1 ) {
@@ -1340,7 +1340,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13401340 if (returnTok == tok)
13411341 continue ;
13421342 for (const ReferenceToken& rt :
1343- followAllReferences (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
1343+ followAllReferencesInternal (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
13441344 const Variable* argvar = rt.token ->variable ();
13451345 if (!argvar) {
13461346 SmallVector<ReferenceToken> refs_result;
@@ -1365,7 +1365,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13651365 er.emplace_back (returnTok, " Return reference." );
13661366 er.emplace_back (tok->previous (), " Called function passing '" + argTok->expressionString () + " '." );
13671367 auto refs =
1368- followAllReferences (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
1368+ followAllReferencesInternal (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
13691369 result.insert (refs.cbegin (), refs.cend ());
13701370 if (!inconclusive && result.size () > 1 ) {
13711371 SmallVector<ReferenceToken> refs_result;
@@ -1386,11 +1386,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13861386 return refs_result;
13871387}
13881388
1389+ SmallVector<ReferenceToken> followAllReferences (const Token* tok, bool temporary)
1390+ {
1391+ return followAllReferencesInternal (tok, temporary);
1392+ }
1393+
13891394const Token* followReferences (const Token* tok, ErrorPath* errors)
13901395{
13911396 if (!tok)
13921397 return nullptr ;
1393- auto refs = followAllReferences (tok, true , false );
1398+ auto refs = followAllReferencesInternal (tok, true , false );
13941399 if (refs.size () == 1 ) {
13951400 if (errors)
13961401 *errors = std::move (refs.front ().errors );
0 commit comments