@@ -1067,7 +1067,7 @@ bool isAliasOf(const Token* tok, const Token* expr, int* indirect)
10671067 const Token* r = nullptr ;
10681068 if (indirect)
10691069 *indirect = 1 ;
1070- for (const ReferenceToken& ref : followAllReferences ( tok)) {
1070+ for (const ReferenceToken& ref : tok-> refs ( )) {
10711071 const bool pointer = astIsPointer (ref.token );
10721072 r = findAstNode (expr, [&](const Token* childTok) {
10731073 if (childTok->exprId () == 0 )
@@ -1246,11 +1246,11 @@ static void followVariableExpressionError(const Token *tok1, const Token *tok2,
12461246 errors->push_back (std::move (item));
12471247}
12481248
1249- SmallVector<ReferenceToken> followAllReferences (const Token* tok,
1250- bool temporary,
1251- bool inconclusive,
1252- ErrorPath errors,
1253- int depth)
1249+ static SmallVector<ReferenceToken> followAllReferencesInternal (const Token* tok,
1250+ bool temporary = true ,
1251+ bool inconclusive = true ,
1252+ ErrorPath errors = ErrorPath{} ,
1253+ int depth = 20 )
12541254{
12551255 struct ReferenceTokenLess {
12561256 bool operator ()(const ReferenceToken& x, const ReferenceToken& y) const {
@@ -1296,16 +1296,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
12961296 return refs_result;
12971297 }
12981298 if (vartok)
1299- return followAllReferences (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
1299+ return followAllReferencesInternal (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
13001300 }
13011301 }
13021302 } else if (Token::simpleMatch (tok, " ?" ) && Token::simpleMatch (tok->astOperand2 (), " :" )) {
13031303 std::set<ReferenceToken, ReferenceTokenLess> result;
13041304 const Token* tok2 = tok->astOperand2 ();
13051305
1306- auto refs = followAllReferences (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
1306+ auto refs = followAllReferencesInternal (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
13071307 result.insert (refs.cbegin (), refs.cend ());
1308- refs = followAllReferences (tok2->astOperand2 (), temporary, inconclusive, errors, depth - 1 );
1308+ refs = followAllReferencesInternal (tok2->astOperand2 (), temporary, inconclusive, errors, depth - 1 );
13091309 result.insert (refs.cbegin (), refs.cend ());
13101310
13111311 if (!inconclusive && result.size () != 1 ) {
@@ -1333,7 +1333,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13331333 if (returnTok == tok)
13341334 continue ;
13351335 for (const ReferenceToken& rt :
1336- followAllReferences (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
1336+ followAllReferencesInternal (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
13371337 const Variable* argvar = rt.token ->variable ();
13381338 if (!argvar) {
13391339 SmallVector<ReferenceToken> refs_result;
@@ -1358,7 +1358,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13581358 er.emplace_back (returnTok, " Return reference." );
13591359 er.emplace_back (tok->previous (), " Called function passing '" + argTok->expressionString () + " '." );
13601360 auto refs =
1361- followAllReferences (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
1361+ followAllReferencesInternal (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
13621362 result.insert (refs.cbegin (), refs.cend ());
13631363 if (!inconclusive && result.size () > 1 ) {
13641364 SmallVector<ReferenceToken> refs_result;
@@ -1379,11 +1379,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
13791379 return refs_result;
13801380}
13811381
1382+ SmallVector<ReferenceToken> followAllReferences (const Token* tok, bool temporary)
1383+ {
1384+ return followAllReferencesInternal (tok, temporary);
1385+ }
1386+
13821387const Token* followReferences (const Token* tok, ErrorPath* errors)
13831388{
13841389 if (!tok)
13851390 return nullptr ;
1386- auto refs = followAllReferences (tok, true , false );
1391+ auto refs = followAllReferencesInternal (tok, true , false );
13871392 if (refs.size () == 1 ) {
13881393 if (errors)
13891394 *errors = std::move (refs.front ().errors );
0 commit comments