parent
828a5e2326
commit
17e562a87f
|
@ -3417,8 +3417,7 @@ struct LifetimeStore {
|
|||
static void forEach(const std::vector<const Token*>& argtoks,
|
||||
const std::string& message,
|
||||
ValueFlow::Value::LifetimeKind type,
|
||||
F f)
|
||||
{
|
||||
F f) {
|
||||
std::map<const Token*, Context> forwardToks;
|
||||
for (const Token* arg : argtoks) {
|
||||
LifetimeStore ls{arg, message, type};
|
||||
|
@ -3459,8 +3458,7 @@ struct LifetimeStore {
|
|||
}
|
||||
|
||||
template <class Predicate>
|
||||
bool byRef(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings, Predicate pred) const
|
||||
{
|
||||
bool byRef(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings, Predicate pred) const {
|
||||
if (!argtok)
|
||||
return false;
|
||||
bool update = false;
|
||||
|
@ -3493,14 +3491,14 @@ struct LifetimeStore {
|
|||
return update;
|
||||
}
|
||||
|
||||
bool byRef(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const
|
||||
{
|
||||
return byRef(tok, tokenlist, errorLogger, settings, [](const Token*) { return true; });
|
||||
bool byRef(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const {
|
||||
return byRef(tok, tokenlist, errorLogger, settings, [](const Token*) {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
template <class Predicate>
|
||||
bool byVal(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings, Predicate pred) const
|
||||
{
|
||||
bool byVal(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings, Predicate pred) const {
|
||||
if (!argtok)
|
||||
return false;
|
||||
bool update = false;
|
||||
|
@ -3559,9 +3557,10 @@ struct LifetimeStore {
|
|||
return update;
|
||||
}
|
||||
|
||||
bool byVal(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const
|
||||
{
|
||||
return byVal(tok, tokenlist, errorLogger, settings, [](const Token*) { return true; });
|
||||
bool byVal(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const {
|
||||
return byVal(tok, tokenlist, errorLogger, settings, [](const Token*) {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
template <class Predicate>
|
||||
|
@ -3594,10 +3593,9 @@ struct LifetimeStore {
|
|||
});
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
Context* mContext;
|
||||
void forwardLifetime(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const
|
||||
{
|
||||
void forwardLifetime(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const {
|
||||
if (mContext) {
|
||||
mContext->tok = tok;
|
||||
mContext->tokenlist = tokenlist;
|
||||
|
@ -3775,7 +3773,9 @@ static void valueFlowLifetimeConstructor(Token* tok, TokenList* tokenlist, Error
|
|||
LifetimeStore::forEach(args,
|
||||
"Passed to initializer list.",
|
||||
ValueFlow::Value::LifetimeKind::Object,
|
||||
[&](const LifetimeStore& ls) { ls.byVal(tok, tokenlist, errorLogger, settings); });
|
||||
[&](const LifetimeStore& ls) {
|
||||
ls.byVal(tok, tokenlist, errorLogger, settings);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
valueFlowLifetimeConstructor(tok, Token::typeOf(tok->previous()), tokenlist, errorLogger, settings);
|
||||
|
|
Loading…
Reference in New Issue