@@ -1064,7 +1064,7 @@ bool isAliasOf(const Token* tok, const Token* expr, int* indirect)
1064
1064
const Token* r = nullptr ;
1065
1065
if (indirect)
1066
1066
*indirect = 1 ;
1067
- for (const ReferenceToken& ref : followAllReferences ( tok)) {
1067
+ for (const ReferenceToken& ref : tok-> refs ( )) {
1068
1068
const bool pointer = astIsPointer (ref.token );
1069
1069
r = findAstNode (expr, [&](const Token* childTok) {
1070
1070
if (childTok->exprId () == 0 )
@@ -1242,11 +1242,11 @@ static void followVariableExpressionError(const Token *tok1, const Token *tok2,
1242
1242
errors->push_back (std::move (item));
1243
1243
}
1244
1244
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 )
1250
1250
{
1251
1251
struct ReferenceTokenLess {
1252
1252
bool operator ()(const ReferenceToken& x, const ReferenceToken& y) const {
@@ -1292,16 +1292,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
1292
1292
return refs_result;
1293
1293
}
1294
1294
if (vartok)
1295
- return followAllReferences (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
1295
+ return followAllReferencesInternal (vartok, temporary, inconclusive, std::move (errors), depth - 1 );
1296
1296
}
1297
1297
}
1298
1298
} else if (Token::simpleMatch (tok, " ?" ) && Token::simpleMatch (tok->astOperand2 (), " :" )) {
1299
1299
std::set<ReferenceToken, ReferenceTokenLess> result;
1300
1300
const Token* tok2 = tok->astOperand2 ();
1301
1301
1302
- auto refs = followAllReferences (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
1302
+ auto refs = followAllReferencesInternal (tok2->astOperand1 (), temporary, inconclusive, errors, depth - 1 );
1303
1303
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 );
1305
1305
result.insert (refs.cbegin (), refs.cend ());
1306
1306
1307
1307
if (!inconclusive && result.size () != 1 ) {
@@ -1329,7 +1329,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
1329
1329
if (returnTok == tok)
1330
1330
continue ;
1331
1331
for (const ReferenceToken& rt :
1332
- followAllReferences (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
1332
+ followAllReferencesInternal (returnTok, temporary, inconclusive, errors, depth - returns.size ())) {
1333
1333
const Variable* argvar = rt.token ->variable ();
1334
1334
if (!argvar) {
1335
1335
SmallVector<ReferenceToken> refs_result;
@@ -1354,7 +1354,7 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
1354
1354
er.emplace_back (returnTok, " Return reference." );
1355
1355
er.emplace_back (tok->previous (), " Called function passing '" + argTok->expressionString () + " '." );
1356
1356
auto refs =
1357
- followAllReferences (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
1357
+ followAllReferencesInternal (argTok, temporary, inconclusive, std::move (er), depth - returns.size ());
1358
1358
result.insert (refs.cbegin (), refs.cend ());
1359
1359
if (!inconclusive && result.size () > 1 ) {
1360
1360
SmallVector<ReferenceToken> refs_result;
@@ -1375,11 +1375,16 @@ SmallVector<ReferenceToken> followAllReferences(const Token* tok,
1375
1375
return refs_result;
1376
1376
}
1377
1377
1378
+ SmallVector<ReferenceToken> followAllReferences (const Token* tok, bool temporary)
1379
+ {
1380
+ return followAllReferencesInternal (tok, temporary);
1381
+ }
1382
+
1378
1383
const Token* followReferences (const Token* tok, ErrorPath* errors)
1379
1384
{
1380
1385
if (!tok)
1381
1386
return nullptr ;
1382
- auto refs = followAllReferences (tok, true , false );
1387
+ auto refs = followAllReferencesInternal (tok, true , false );
1383
1388
if (refs.size () == 1 ) {
1384
1389
if (errors)
1385
1390
*errors = std::move (refs.front ().errors );
0 commit comments