Add source traces when using LifetimeStore (#4678)
This commit is contained in:
parent
4c1c506d21
commit
a338be4682
|
@ -3925,7 +3925,13 @@ 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,
|
||||
SourceLocation loc = SourceLocation::current()) const
|
||||
{
|
||||
if (!argtok)
|
||||
return false;
|
||||
bool update = false;
|
||||
|
@ -3950,6 +3956,8 @@ struct LifetimeStore {
|
|||
// Don't add the value a second time
|
||||
if (std::find(tok->values().cbegin(), tok->values().cend(), value) != tok->values().cend())
|
||||
return false;
|
||||
if (settings->debugnormal)
|
||||
setSourceLocation(value, loc, tok);
|
||||
setTokenValue(tok, value, tokenlist->getSettings());
|
||||
update = true;
|
||||
}
|
||||
|
@ -3958,14 +3966,31 @@ struct LifetimeStore {
|
|||
return update;
|
||||
}
|
||||
|
||||
bool byRef(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const {
|
||||
return byRef(tok, tokenlist, errorLogger, settings, [](const Token*) {
|
||||
bool byRef(Token* tok,
|
||||
TokenList* tokenlist,
|
||||
ErrorLogger* errorLogger,
|
||||
const Settings* settings,
|
||||
SourceLocation loc = SourceLocation::current()) const
|
||||
{
|
||||
return byRef(
|
||||
tok,
|
||||
tokenlist,
|
||||
errorLogger,
|
||||
settings,
|
||||
[](const Token*) {
|
||||
return true;
|
||||
});
|
||||
},
|
||||
loc);
|
||||
}
|
||||
|
||||
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,
|
||||
SourceLocation loc = SourceLocation::current()) const
|
||||
{
|
||||
if (!argtok)
|
||||
return false;
|
||||
bool update = false;
|
||||
|
@ -3991,7 +4016,8 @@ struct LifetimeStore {
|
|||
// Don't add the value a second time
|
||||
if (std::find(tok->values().cbegin(), tok->values().cend(), value) != tok->values().cend())
|
||||
continue;
|
||||
|
||||
if (settings->debugnormal)
|
||||
setSourceLocation(value, loc, tok);
|
||||
setTokenValue(tok, value, tokenlist->getSettings());
|
||||
update = true;
|
||||
}
|
||||
|
@ -4024,6 +4050,8 @@ struct LifetimeStore {
|
|||
// Don't add the value a second time
|
||||
if (std::find(tok->values().cbegin(), tok->values().cend(), value) != tok->values().cend())
|
||||
continue;
|
||||
if (settings->debugnormal)
|
||||
setSourceLocation(value, loc, tok);
|
||||
setTokenValue(tok, value, tokenlist->getSettings());
|
||||
update = true;
|
||||
}
|
||||
|
@ -4033,14 +4061,31 @@ struct LifetimeStore {
|
|||
return update;
|
||||
}
|
||||
|
||||
bool byVal(Token* tok, TokenList* tokenlist, ErrorLogger* errorLogger, const Settings* settings) const {
|
||||
return byVal(tok, tokenlist, errorLogger, settings, [](const Token*) {
|
||||
bool byVal(Token* tok,
|
||||
TokenList* tokenlist,
|
||||
ErrorLogger* errorLogger,
|
||||
const Settings* settings,
|
||||
SourceLocation loc = SourceLocation::current()) const
|
||||
{
|
||||
return byVal(
|
||||
tok,
|
||||
tokenlist,
|
||||
errorLogger,
|
||||
settings,
|
||||
[](const Token*) {
|
||||
return true;
|
||||
});
|
||||
},
|
||||
loc);
|
||||
}
|
||||
|
||||
template<class Predicate>
|
||||
void byDerefCopy(Token *tok, TokenList *tokenlist, ErrorLogger *errorLogger, const Settings *settings, Predicate pred) const {
|
||||
void byDerefCopy(Token* tok,
|
||||
TokenList* tokenlist,
|
||||
ErrorLogger* errorLogger,
|
||||
const Settings* settings,
|
||||
Predicate pred,
|
||||
SourceLocation loc = SourceLocation::current()) const
|
||||
{
|
||||
if (!settings->certainty.isEnabled(Certainty::inconclusive) && inconclusive)
|
||||
return;
|
||||
if (!argtok)
|
||||
|
@ -4060,17 +4105,28 @@ struct LifetimeStore {
|
|||
const Token * const varDeclEndToken = var->declEndToken();
|
||||
for (const Token *tok3 = tok; tok3 && tok3 != varDeclEndToken; tok3 = tok3->previous()) {
|
||||
if (tok3->varId() == var->declarationId()) {
|
||||
LifetimeStore{tok3, message, type, inconclusive}.byVal(tok, tokenlist, errorLogger, settings, pred);
|
||||
LifetimeStore{tok3, message, type, inconclusive}.byVal(tok, tokenlist, errorLogger, settings, pred, loc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void byDerefCopy(Token *tok, TokenList *tokenlist, ErrorLogger *errorLogger, const Settings *settings) const {
|
||||
byDerefCopy(tok, tokenlist, errorLogger, settings, [](const Token *) {
|
||||
void byDerefCopy(Token* tok,
|
||||
TokenList* tokenlist,
|
||||
ErrorLogger* errorLogger,
|
||||
const Settings* settings,
|
||||
SourceLocation loc = SourceLocation::current()) const
|
||||
{
|
||||
byDerefCopy(
|
||||
tok,
|
||||
tokenlist,
|
||||
errorLogger,
|
||||
settings,
|
||||
[](const Token*) {
|
||||
return true;
|
||||
});
|
||||
},
|
||||
loc);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue