Skip to content

Commit e799f3c

Browse files
committed
Scope: removed unnecessary Settings parameter from checkVariable()
1 parent 6c9d21c commit e799f3c

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

Diff for: lib/symboldatabase.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -731,9 +731,9 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
731731
scope->nestedList.push_back(&scopeList.back());
732732
scope = &scopeList.back();
733733
if (scope->type == Scope::eFor)
734-
scope->checkVariable(tok->tokAt(2), AccessControl::Local, mTokenizer.getSettings()); // check for variable declaration and add it to new scope if found
734+
scope->checkVariable(tok->tokAt(2), AccessControl::Local); // check for variable declaration and add it to new scope if found
735735
else if (scope->type == Scope::eCatch)
736-
scope->checkVariable(tok->tokAt(2), AccessControl::Throw, mTokenizer.getSettings()); // check for variable declaration and add it to new scope if found
736+
scope->checkVariable(tok->tokAt(2), AccessControl::Throw); // check for variable declaration and add it to new scope if found
737737
tok = tok->next();
738738
inIfCondition.push(scopeStartTok);
739739
} else if (Token::Match(tok, "%var% {")) {
@@ -4814,7 +4814,7 @@ void Scope::getVariableList(const Token* start, const Token* end)
48144814
{
48154815
// Variable declared in condition: if (auto x = bar())
48164816
if (Token::Match(classDef, "if|while ( %type%") && Token::simpleMatch(classDef->next()->astOperand2(), "=")) {
4817-
checkVariable(classDef->tokAt(2), defaultAccess(), symdb->mTokenizer.getSettings());
4817+
checkVariable(classDef->tokAt(2), defaultAccess());
48184818
}
48194819

48204820
AccessControl varaccess = defaultAccess();
@@ -4911,14 +4911,14 @@ void Scope::getVariableList(const Token* start, const Token* end)
49114911
if (tok->str() == ";")
49124912
continue;
49134913

4914-
tok = checkVariable(tok, varaccess, symdb->mTokenizer.getSettings());
4914+
tok = checkVariable(tok, varaccess);
49154915

49164916
if (!tok)
49174917
break;
49184918
}
49194919
}
49204920

4921-
const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, const Settings& settings)
4921+
const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess)
49224922
{
49234923
// Is it a throw..?
49244924
if (tok->isKeyword() && Token::Match(tok, "throw %any% (") &&
@@ -4948,7 +4948,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con
49484948
const Token *typestart = tok;
49494949

49504950
// C++17 structured bindings
4951-
if (tok && tok->isCpp() && (settings.standards.cpp >= Standards::CPP17) && Token::Match(tok, "auto &|&&| [")) {
4951+
if (tok && tok->isCpp() && (symdb->mTokenizer.getSettings().standards.cpp >= Standards::CPP17) && Token::Match(tok, "auto &|&&| [")) {
49524952
const Token *typeend = Token::findsimplematch(typestart, "[")->previous();
49534953
for (tok = typeend->tokAt(2); Token::Match(tok, "%name%|,"); tok = tok->next()) {
49544954
if (tok->varId())

Diff for: lib/symboldatabase.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -1170,10 +1170,9 @@ class CPPCHECKLIB Scope {
11701170
* @brief check if statement is variable declaration and add it if it is
11711171
* @param tok pointer to start of statement
11721172
* @param varaccess access control of statement
1173-
* @param settings Settings
11741173
* @return pointer to last token
11751174
*/
1176-
const Token *checkVariable(const Token *tok, AccessControl varaccess, const Settings& settings);
1175+
const Token *checkVariable(const Token *tok, AccessControl varaccess);
11771176

11781177
/**
11791178
* @brief get variable from name

0 commit comments

Comments
 (0)