@@ -2362,19 +2362,20 @@ struct LifetimeStore {
2362
2362
for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens (argtok, settings)) {
2363
2363
if (!settings.certainty .isEnabled (Certainty::inconclusive) && lt.inconclusive )
2364
2364
continue ;
2365
+
2366
+ const Variable* var = lt.token ->variable ();
2367
+ if (!var || !var->isArgument ())
2368
+ continue ;
2369
+
2365
2370
ValueFlow::Value value;
2366
2371
value.valueType = ValueFlow::Value::ValueType::LIFETIME;
2367
2372
value.tokvalue = lt.token ;
2368
2373
value.capturetok = argtok;
2369
2374
value.errorPath = er;
2370
2375
value.lifetimeKind = type;
2371
2376
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
+
2378
2379
// Don't add the value a second time
2379
2380
if (std::find (tok->values ().cbegin (), tok->values ().cend (), value) != tok->values ().cend ())
2380
2381
continue ;
@@ -2391,12 +2392,12 @@ struct LifetimeStore {
2391
2392
for (const ValueFlow::LifetimeToken& lt : ValueFlow::getLifetimeTokens (tok3, settings)) {
2392
2393
if (!settings.certainty .isEnabled (Certainty::inconclusive) && lt.inconclusive )
2393
2394
continue ;
2394
- ErrorPath er = v.errorPath ;
2395
- er.insert (er.end (), lt.errorPath .cbegin (), lt.errorPath .cend ());
2396
2395
if (!lt.token )
2397
2396
return false ;
2398
2397
if (!pred (lt.token ))
2399
2398
return false ;
2399
+ ErrorPath er = v.errorPath ;
2400
+ er.insert (er.end (), lt.errorPath .cbegin (), lt.errorPath .cend ());
2400
2401
er.emplace_back (argtok, message);
2401
2402
er.insert (er.end (), errorPath.cbegin (), errorPath.cend ());
2402
2403
@@ -5889,11 +5890,12 @@ static void valueFlowFunctionDefaultParameter(const TokenList& tokenlist, const
5889
5890
const std::list<ValueFlow::Value> &values = var->nameToken ()->tokAt (2 )->values ();
5890
5891
std::list<ValueFlow::Value> argvalues;
5891
5892
for (const ValueFlow::Value &value : values) {
5893
+ if (!value.isKnown ())
5894
+ continue ;
5892
5895
ValueFlow::Value v (value);
5893
5896
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));
5897
5899
}
5898
5900
if (!argvalues.empty ())
5899
5901
valueFlowInjectParameter (tokenlist, errorLogger, settings, var, scope, argvalues);
0 commit comments