@@ -865,6 +865,34 @@ bool isAliasOf(const Token *tok, nonneg int varid, bool* inconclusive)
865865 return false ;
866866}
867867
868+ bool isAliasOf (const Token* tok, const Token* expr, bool * inconclusive)
869+ {
870+ const bool pointer = astIsPointer (tok);
871+ const ValueFlow::Value* value = nullptr ;
872+ const Token* r = findAstNode (expr, [&](const Token* childTok) {
873+ for (const ValueFlow::Value& val : tok->values ()) {
874+ if (val.isImpossible ())
875+ continue ;
876+ if (val.isLocalLifetimeValue () || (pointer && val.isSymbolicValue () && val.intvalue == 0 )) {
877+ if (findAstNode (val.tokvalue ,
878+ [&](const Token* aliasTok) {
879+ return aliasTok->exprId () == childTok->exprId ();
880+ })) {
881+ if (val.isInconclusive () && inconclusive) { // NOLINT
882+ value = &val;
883+ } else {
884+ return true ;
885+ }
886+ }
887+ }
888+ }
889+ return false ;
890+ });
891+ if (!r && value && inconclusive)
892+ *inconclusive = true ;
893+ return r || value;
894+ }
895+
868896static bool isAliased (const Token *startTok, const Token *endTok, nonneg int varid)
869897{
870898 if (!precedes (startTok, endTok))
@@ -2452,27 +2480,12 @@ static bool isExpressionChangedAt(const F& getExprTok,
24522480 if (globalvar && !tok->isKeyword () && Token::Match (tok, " %name% (" ) && !(tok->function () && tok->function ()->isAttributePure ()))
24532481 // TODO: Is global variable really changed by function call?
24542482 return true ;
2455- const bool pointer = astIsPointer (tok);
24562483 bool aliased = false ;
24572484 // If we can't find the expression then assume it is an alias
24582485 if (!getExprTok ())
24592486 aliased = true ;
2460- if (!aliased) {
2461- aliased = findAstNode (getExprTok (), [&](const Token* childTok) {
2462- for (const ValueFlow::Value& val : tok->values ()) {
2463- if (val.isImpossible ())
2464- continue ;
2465- if (val.isLocalLifetimeValue () || (pointer && val.isSymbolicValue () && val.intvalue == 0 )) {
2466- if (findAstNode (val.tokvalue ,
2467- [&](const Token* aliasTok) {
2468- return aliasTok->exprId () == childTok->exprId ();
2469- }))
2470- return true ;
2471- }
2472- }
2473- return false ;
2474- });
2475- }
2487+ if (!aliased)
2488+ aliased = isAliasOf (tok, getExprTok ());
24762489 if (!aliased)
24772490 return false ;
24782491 if (isVariableChanged (tok, 1 , settings, cpp, depth))
0 commit comments