astyle formatting

[ci skip]
This commit is contained in:
Daniel Marjamäki 2020-10-03 11:02:11 +02:00
parent 828a5e2326
commit 17e562a87f
1 changed files with 34 additions and 34 deletions

View File

@ -3417,8 +3417,7 @@ struct LifetimeStore {
static void forEach(const std::vector<const Token*>& argtoks, static void forEach(const std::vector<const Token*>& argtoks,
const std::string& message, const std::string& message,
ValueFlow::Value::LifetimeKind type, ValueFlow::Value::LifetimeKind type,
F f) F f) {
{
std::map<const Token*, Context> forwardToks; std::map<const Token*, Context> forwardToks;
for (const Token* arg : argtoks) { for (const Token* arg : argtoks) {
LifetimeStore ls{arg, message, type}; LifetimeStore ls{arg, message, type};
@ -3459,8 +3458,7 @@ struct LifetimeStore {
} }
template <class Predicate> 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) if (!argtok)
return false; return false;
bool update = false; bool update = false;
@ -3493,14 +3491,14 @@ struct LifetimeStore {
return update; return update;
} }
bool byRef(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const bool byRef(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const {
{ return byRef(tok, tokenlist, errorLogger, settings, [](const Token*) {
return byRef(tok, tokenlist, errorLogger, settings, [](const Token*) { return true; }); return true;
});
} }
template <class Predicate> 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) if (!argtok)
return false; return false;
bool update = false; bool update = false;
@ -3559,9 +3557,10 @@ struct LifetimeStore {
return update; return update;
} }
bool byVal(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const bool byVal(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const {
{ return byVal(tok, tokenlist, errorLogger, settings, [](const Token*) {
return byVal(tok, tokenlist, errorLogger, settings, [](const Token*) { return true; }); return true;
});
} }
template <class Predicate> template <class Predicate>
@ -3594,10 +3593,9 @@ struct LifetimeStore {
}); });
} }
private: private:
Context* mContext; 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) { if (mContext) {
mContext->tok = tok; mContext->tok = tok;
mContext->tokenlist = tokenlist; mContext->tokenlist = tokenlist;
@ -3711,10 +3709,10 @@ static void valueFlowLifetimeConstructor(Token* tok,
// constructor, but make each lifetime inconclusive // constructor, but make each lifetime inconclusive
std::vector<const Token*> args = getArguments(tok); std::vector<const Token*> args = getArguments(tok);
LifetimeStore::forEach( LifetimeStore::forEach(
args, "Passed to initializer list.", ValueFlow::Value::LifetimeKind::Object, [&](LifetimeStore& ls) { args, "Passed to initializer list.", ValueFlow::Value::LifetimeKind::Object, [&](LifetimeStore& ls) {
ls.inconclusive = true; ls.inconclusive = true;
ls.byVal(tok, tokenlist, errorLogger, settings); ls.byVal(tok, tokenlist, errorLogger, settings);
}); });
return; return;
} }
const Scope* scope = t->classScope; const Scope* scope = t->classScope;
@ -3727,17 +3725,17 @@ static void valueFlowLifetimeConstructor(Token* tok,
LifetimeStore::forEach(args, LifetimeStore::forEach(args,
"Passed to constructor of '" + t->name() + "'.", "Passed to constructor of '" + t->name() + "'.",
ValueFlow::Value::LifetimeKind::Object, ValueFlow::Value::LifetimeKind::Object,
[&](const LifetimeStore& ls) { [&](const LifetimeStore& ls) {
if (it == scope->varlist.end()) if (it == scope->varlist.end())
return; return;
const Variable& var = *it; const Variable& var = *it;
if (var.isReference() || var.isRValueReference()) { if (var.isReference() || var.isRValueReference()) {
ls.byRef(tok, tokenlist, errorLogger, settings); ls.byRef(tok, tokenlist, errorLogger, settings);
} else { } else {
ls.byVal(tok, tokenlist, errorLogger, settings); ls.byVal(tok, tokenlist, errorLogger, settings);
} }
it++; it++;
}); });
} }
} }
@ -3768,14 +3766,16 @@ static void valueFlowLifetimeConstructor(Token* tok, TokenList* tokenlist, Error
// Assume range constructor if passed a pair of iterators // Assume range constructor if passed a pair of iterators
if (astIsContainer(parent) && args.size() == 2 && astIsIterator(args[0]) && astIsIterator(args[1])) { if (astIsContainer(parent) && args.size() == 2 && astIsIterator(args[0]) && astIsIterator(args[1])) {
LifetimeStore::forEach( LifetimeStore::forEach(
args, "Passed to initializer list.", ValueFlow::Value::LifetimeKind::Object, [&](const LifetimeStore& ls) { args, "Passed to initializer list.", ValueFlow::Value::LifetimeKind::Object, [&](const LifetimeStore& ls) {
ls.byDerefCopy(tok, tokenlist, errorLogger, settings); ls.byDerefCopy(tok, tokenlist, errorLogger, settings);
}); });
} else { } else {
LifetimeStore::forEach(args, LifetimeStore::forEach(args,
"Passed to initializer list.", "Passed to initializer list.",
ValueFlow::Value::LifetimeKind::Object, ValueFlow::Value::LifetimeKind::Object,
[&](const LifetimeStore& ls) { ls.byVal(tok, tokenlist, errorLogger, settings); }); [&](const LifetimeStore& ls) {
ls.byVal(tok, tokenlist, errorLogger, settings);
});
} }
} else { } else {
valueFlowLifetimeConstructor(tok, Token::typeOf(tok->previous()), tokenlist, errorLogger, settings); valueFlowLifetimeConstructor(tok, Token::typeOf(tok->previous()), tokenlist, errorLogger, settings);