@@ -2362,19 +2362,20 @@ struct LifetimeStore {
23622362 for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens (argtok, settings)) {
23632363 if (!settings.certainty .isEnabled (Certainty::inconclusive) && lt.inconclusive )
23642364 continue ;
2365+
2366+ const Variable* var = lt.token ->variable ();
2367+ if (!var || !var->isArgument ())
2368+ continue ;
2369+
23652370 ValueFlow::Value value;
23662371 value.valueType = ValueFlow::Value::ValueType::LIFETIME;
23672372 value.tokvalue = lt.token ;
23682373 value.capturetok = argtok;
23692374 value.errorPath = er;
23702375 value.lifetimeKind = type;
23712376 value.setInconclusive (inconclusive || lt.inconclusive );
2372- const Variable* var = lt.token ->variable ();
2373- if (var && var->isArgument ()) {
2374- value.lifetimeScope = ValueFlow::Value::LifetimeScope::Argument;
2375- } else {
2376- continue ;
2377- }
2377+ value.lifetimeScope = ValueFlow::Value::LifetimeScope::Argument;
2378+
23782379 // Don't add the value a second time
23792380 if (std::find (tok->values ().cbegin (), tok->values ().cend (), value) != tok->values ().cend ())
23802381 continue ;
@@ -2391,12 +2392,12 @@ struct LifetimeStore {
23912392 for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens (tok3, settings)) {
23922393 if (!settings.certainty .isEnabled (Certainty::inconclusive) && lt.inconclusive )
23932394 continue ;
2394- ErrorPath er = v.errorPath ;
2395- er.insert (er.end (), lt.errorPath .cbegin (), lt.errorPath .cend ());
23962395 if (!lt.token )
23972396 return false ;
23982397 if (!pred (lt.token ))
23992398 return false ;
2399+ ErrorPath er = v.errorPath ;
2400+ er.insert (er.end (), lt.errorPath .cbegin (), lt.errorPath .cend ());
24002401 er.emplace_back (argtok, message);
24012402 er.insert (er.end (), errorPath.cbegin (), errorPath.cend ());
24022403
@@ -5889,11 +5890,12 @@ static void valueFlowFunctionDefaultParameter(const TokenList& tokenlist, const
58895890 const std::list<ValueFlow::Value> &values = var->nameToken ()->tokAt (2 )->values ();
58905891 std::list<ValueFlow::Value> argvalues;
58915892 for (const ValueFlow::Value &value : values) {
5893+ if (!value.isKnown ())
5894+ continue ;
58925895 ValueFlow::Value v (value);
58935896 v.defaultArg = true ;
5894- v.changeKnownToPossible ();
5895- if (v.isPossible ())
5896- argvalues.push_back (std::move (v));
5897+ v.setPossible ();
5898+ argvalues.push_back (std::move (v));
58975899 }
58985900 if (!argvalues.empty ())
58995901 valueFlowInjectParameter (tokenlist, errorLogger, settings, var, scope, argvalues);
0 commit comments