@@ -3417,8 +3417,7 @@ struct LifetimeStore {
34173417 static void forEach (const std::vector<const Token*>& argtoks,
34183418 const std::string& message,
34193419 ValueFlow::Value::LifetimeKind type,
3420- F f)
3421- {
3420+ F f) {
34223421 std::map<const Token*, Context> forwardToks;
34233422 for (const Token* arg : argtoks) {
34243423 LifetimeStore ls{arg, message, type};
@@ -3459,8 +3458,7 @@ struct LifetimeStore {
34593458 }
34603459
34613460 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 {
34643462 if (!argtok)
34653463 return false ;
34663464 bool update = false ;
@@ -3493,14 +3491,14 @@ struct LifetimeStore {
34933491 return update;
34943492 }
34953493
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+ });
34993498 }
35003499
35013500 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 {
35043502 if (!argtok)
35053503 return false ;
35063504 bool update = false ;
@@ -3559,9 +3557,10 @@ struct LifetimeStore {
35593557 return update;
35603558 }
35613559
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+ });
35653564 }
35663565
35673566 template <class Predicate >
@@ -3594,10 +3593,9 @@ struct LifetimeStore {
35943593 });
35953594 }
35963595
3597- private:
3596+ private:
35983597 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 {
36013599 if (mContext ) {
36023600 mContext ->tok = tok;
36033601 mContext ->tokenlist = tokenlist;
@@ -3711,10 +3709,10 @@ static void valueFlowLifetimeConstructor(Token* tok,
37113709 // constructor, but make each lifetime inconclusive
37123710 std::vector<const Token*> args = getArguments (tok);
37133711 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+ });
37183716 return ;
37193717 }
37203718 const Scope* scope = t->classScope ;
@@ -3727,17 +3725,17 @@ static void valueFlowLifetimeConstructor(Token* tok,
37273725 LifetimeStore::forEach (args,
37283726 " Passed to constructor of '" + t->name () + " '." ,
37293727 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+ });
37413739 }
37423740}
37433741
@@ -3768,14 +3766,16 @@ static void valueFlowLifetimeConstructor(Token* tok, TokenList* tokenlist, Error
37683766 // Assume range constructor if passed a pair of iterators
37693767 if (astIsContainer (parent) && args.size () == 2 && astIsIterator (args[0 ]) && astIsIterator (args[1 ])) {
37703768 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+ });
37743772 } else {
37753773 LifetimeStore::forEach (args,
37763774 " Passed to initializer list." ,
37773775 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+ });
37793779 }
37803780 } else {
37813781 valueFlowLifetimeConstructor (tok, Token::typeOf (tok->previous ()), tokenlist, errorLogger, settings);
0 commit comments