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