@@ -1934,11 +1934,9 @@ static void valueFlowForwardLifetime(Token * tok, const TokenList &tokenlist, Er
19341934 if (!expr)
19351935 return ;
19361936
1937- if (expr->exprId () = = 0 )
1937+ if (expr->exprId () < = 0 )
19381938 return ;
19391939
1940- const Token* endOfVarScope = ValueFlow::getEndOfExprScope (expr);
1941-
19421940 // Only forward lifetime values
19431941 std::list<ValueFlow::Value> values = parent->astOperand2 ()->values ();
19441942 values.remove_if (&isNotLifetimeValue);
@@ -1951,21 +1949,21 @@ static void valueFlowForwardLifetime(Token * tok, const TokenList &tokenlist, Er
19511949
19521950 // Skip RHS
19531951 Token* nextExpression = nextAfterAstRightmostLeaf (parent);
1952+ const Token* endOfVarScope = ValueFlow::getEndOfExprScope (expr);
19541953
1955- if (expr->exprId () > 0 ) {
1956- valueFlowForward (nextExpression, endOfVarScope->next (), expr, values, tokenlist, errorLogger, settings);
1954+ valueFlowForward (nextExpression, endOfVarScope->next (), expr, values, tokenlist, errorLogger, settings);
19571955
1956+ // TODO: handle `[`
1957+ if (Token::simpleMatch (parent->astOperand1 (), " ." )) {
19581958 for (ValueFlow::Value& val : values) {
19591959 if (val.lifetimeKind == ValueFlow::Value::LifetimeKind::Address)
19601960 val.lifetimeKind = ValueFlow::Value::LifetimeKind::SubObject;
19611961 }
1962- // TODO: handle `[`
1963- if (Token::simpleMatch (parent->astOperand1 (), " ." )) {
1964- const Token* parentLifetime =
1965- getParentLifetime (parent->astOperand1 ()->astOperand2 (), settings.library );
1966- if (parentLifetime && parentLifetime->exprId () > 0 ) {
1967- valueFlowForward (nextExpression, endOfVarScope, parentLifetime, std::move (values), tokenlist, errorLogger, settings);
1968- }
1962+
1963+ const Token* parentLifetime =
1964+ getParentLifetime (parent->astOperand1 ()->astOperand2 (), settings.library );
1965+ if (parentLifetime && parentLifetime->exprId () > 0 ) {
1966+ valueFlowForward (nextExpression, endOfVarScope, parentLifetime, std::move (values), tokenlist, errorLogger, settings);
19691967 }
19701968 }
19711969 // Constructor
0 commit comments