pass `TokenList` as reference into `ValueFlow::setValues()` (#4868)

This avoid lots of unchecked pointer dereferences.

There was a single case which checked it and that looked like a
leftover. The only way this might have been a `nullptr` pointer was
through several default constructors which were not used at all so I
removed them.
This commit is contained in:
Oliver Stöneberg 2023-08-04 18:17:27 +02:00 committed by GitHub
parent b2511fb3ae
commit 77c479a6c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 152 additions and 169 deletions

View File

@ -544,7 +544,7 @@ unsigned int CppCheck::check(const std::string &path)
Tokenizer tokenizer(&mSettings, this);
tokenizer.list.appendFileIfNew(path);
clangimport::parseClangAstDump(&tokenizer, ast);
ValueFlow::setValues(&tokenizer.list,
ValueFlow::setValues(tokenizer.list,
const_cast<SymbolDatabase*>(tokenizer.getSymbolDatabase()),
this,
&mSettings,

View File

@ -3361,9 +3361,9 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration)
if (doValueFlow) {
if (mTimerResults) {
Timer t("Tokenizer::simplifyTokens1::ValueFlow", mSettings->showtime, mTimerResults);
ValueFlow::setValues(&list, mSymbolDatabase, mErrorLogger, mSettings, mTimerResults);
ValueFlow::setValues(list, mSymbolDatabase, mErrorLogger, mSettings, mTimerResults);
} else {
ValueFlow::setValues(&list, mSymbolDatabase, mErrorLogger, mSettings, mTimerResults);
ValueFlow::setValues(list, mSymbolDatabase, mErrorLogger, mSettings, mTimerResults);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -51,7 +51,7 @@ namespace ValueFlow {
const Value * valueFlowConstantFoldAST(Token *expr, const Settings *settings);
/// Perform valueflow analysis.
void setValues(TokenList* tokenlist,
void setValues(TokenList& tokenlist,
SymbolDatabase* symboldatabase,
ErrorLogger* errorLogger,
const Settings* settings,