@@ -3417,8 +3417,7 @@ struct LifetimeStore {
3417
3417
static void forEach (const std::vector<const Token*>& argtoks,
3418
3418
const std::string& message,
3419
3419
ValueFlow::Value::LifetimeKind type,
3420
- F f)
3421
- {
3420
+ F f) {
3422
3421
std::map<const Token*, Context> forwardToks;
3423
3422
for (const Token* arg : argtoks) {
3424
3423
LifetimeStore ls{arg, message, type};
@@ -3459,8 +3458,7 @@ struct LifetimeStore {
3459
3458
}
3460
3459
3461
3460
template <class Predicate >
3462
- bool byRef (Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings, Predicate pred) const
3463
- {
3461
+ bool byRef (Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings, Predicate pred) const {
3464
3462
if (!argtok)
3465
3463
return false ;
3466
3464
bool update = false ;
@@ -3493,14 +3491,14 @@ struct LifetimeStore {
3493
3491
return update;
3494
3492
}
3495
3493
3496
- bool byRef (Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const
3497
- {
3498
- return byRef (tok, tokenlist, errorLogger, settings, [](const Token*) { return true ; });
3494
+ bool byRef (Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const {
3495
+ return byRef (tok, tokenlist, errorLogger, settings, [](const Token*) {
3496
+ return true ;
3497
+ });
3499
3498
}
3500
3499
3501
3500
template <class Predicate >
3502
- bool byVal (Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings, Predicate pred) const
3503
- {
3501
+ bool byVal (Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings, Predicate pred) const {
3504
3502
if (!argtok)
3505
3503
return false ;
3506
3504
bool update = false ;
@@ -3559,9 +3557,10 @@ struct LifetimeStore {
3559
3557
return update;
3560
3558
}
3561
3559
3562
- bool byVal (Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const
3563
- {
3564
- return byVal (tok, tokenlist, errorLogger, settings, [](const Token*) { return true ; });
3560
+ bool byVal (Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const {
3561
+ return byVal (tok, tokenlist, errorLogger, settings, [](const Token*) {
3562
+ return true ;
3563
+ });
3565
3564
}
3566
3565
3567
3566
template <class Predicate >
@@ -3594,10 +3593,9 @@ struct LifetimeStore {
3594
3593
});
3595
3594
}
3596
3595
3597
- private:
3596
+ private:
3598
3597
Context* mContext ;
3599
- void forwardLifetime (Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const
3600
- {
3598
+ void forwardLifetime (Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const {
3601
3599
if (mContext ) {
3602
3600
mContext ->tok = tok;
3603
3601
mContext ->tokenlist = tokenlist;
@@ -3711,10 +3709,10 @@ static void valueFlowLifetimeConstructor(Token* tok,
3711
3709
// constructor, but make each lifetime inconclusive
3712
3710
std::vector<const Token*> args = getArguments (tok);
3713
3711
LifetimeStore::forEach (
3714
- args, " Passed to initializer list." , ValueFlow::Value::LifetimeKind::Object, [&](LifetimeStore& ls) {
3715
- ls.inconclusive = true ;
3716
- ls.byVal (tok, tokenlist, errorLogger, settings);
3717
- });
3712
+ args, " Passed to initializer list." , ValueFlow::Value::LifetimeKind::Object, [&](LifetimeStore& ls) {
3713
+ ls.inconclusive = true ;
3714
+ ls.byVal (tok, tokenlist, errorLogger, settings);
3715
+ });
3718
3716
return ;
3719
3717
}
3720
3718
const Scope* scope = t->classScope ;
@@ -3727,17 +3725,17 @@ static void valueFlowLifetimeConstructor(Token* tok,
3727
3725
LifetimeStore::forEach (args,
3728
3726
" Passed to constructor of '" + t->name () + " '." ,
3729
3727
ValueFlow::Value::LifetimeKind::Object,
3730
- [&](const LifetimeStore& ls) {
3731
- if (it == scope->varlist .end ())
3732
- return ;
3733
- const Variable& var = *it;
3734
- if (var.isReference () || var.isRValueReference ()) {
3735
- ls.byRef (tok, tokenlist, errorLogger, settings);
3736
- } else {
3737
- ls.byVal (tok, tokenlist, errorLogger, settings);
3738
- }
3739
- it++;
3740
- });
3728
+ [&](const LifetimeStore& ls) {
3729
+ if (it == scope->varlist .end ())
3730
+ return ;
3731
+ const Variable& var = *it;
3732
+ if (var.isReference () || var.isRValueReference ()) {
3733
+ ls.byRef (tok, tokenlist, errorLogger, settings);
3734
+ } else {
3735
+ ls.byVal (tok, tokenlist, errorLogger, settings);
3736
+ }
3737
+ it++;
3738
+ });
3741
3739
}
3742
3740
}
3743
3741
@@ -3768,14 +3766,16 @@ static void valueFlowLifetimeConstructor(Token* tok, TokenList* tokenlist, Error
3768
3766
// Assume range constructor if passed a pair of iterators
3769
3767
if (astIsContainer (parent) && args.size () == 2 && astIsIterator (args[0 ]) && astIsIterator (args[1 ])) {
3770
3768
LifetimeStore::forEach (
3771
- args, " Passed to initializer list." , ValueFlow::Value::LifetimeKind::Object, [&](const LifetimeStore& ls) {
3772
- ls.byDerefCopy (tok, tokenlist, errorLogger, settings);
3773
- });
3769
+ args, " Passed to initializer list." , ValueFlow::Value::LifetimeKind::Object, [&](const LifetimeStore& ls) {
3770
+ ls.byDerefCopy (tok, tokenlist, errorLogger, settings);
3771
+ });
3774
3772
} else {
3775
3773
LifetimeStore::forEach (args,
3776
3774
" Passed to initializer list." ,
3777
3775
ValueFlow::Value::LifetimeKind::Object,
3778
- [&](const LifetimeStore& ls) { ls.byVal (tok, tokenlist, errorLogger, settings); });
3776
+ [&](const LifetimeStore& ls) {
3777
+ ls.byVal (tok, tokenlist, errorLogger, settings);
3778
+ });
3779
3779
}
3780
3780
} else {
3781
3781
valueFlowLifetimeConstructor (tok, Token::typeOf (tok->previous ()), tokenlist, errorLogger, settings);
0 commit comments