Skip to content

Commit 0a880e9

Browse files
committed
Scope: removed unnecessary Settings parameter from checkVariable()
1 parent 21dfe6f commit 0a880e9

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% {")) {
@@ -4817,7 +4817,7 @@ void Scope::getVariableList(const Token* start, const Token* end)
48174817
{
48184818
// Variable declared in condition: if (auto x = bar())
48194819
if (Token::Match(classDef, "if|while ( %type%") && Token::simpleMatch(classDef->next()->astOperand2(), "=")) {
4820-
checkVariable(classDef->tokAt(2), defaultAccess(), symdb->mTokenizer.getSettings());
4820+
checkVariable(classDef->tokAt(2), defaultAccess());
48214821
}
48224822

48234823
AccessControl varaccess = defaultAccess();
@@ -4914,14 +4914,14 @@ void Scope::getVariableList(const Token* start, const Token* end)
49144914
if (tok->str() == ";")
49154915
continue;
49164916

4917-
tok = checkVariable(tok, varaccess, symdb->mTokenizer.getSettings());
4917+
tok = checkVariable(tok, varaccess);
49184918

49194919
if (!tok)
49204920
break;
49214921
}
49224922
}
49234923

4924-
const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, const Settings& settings)
4924+
const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess)
49254925
{
49264926
// Is it a throw..?
49274927
if (tok->isKeyword() && Token::Match(tok, "throw %any% (") &&
@@ -4951,7 +4951,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con
49514951
const Token *typestart = tok;
49524952

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

Diff for: lib/symboldatabase.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -1178,10 +1178,9 @@ class CPPCHECKLIB Scope {
11781178
* @brief check if statement is variable declaration and add it if it is
11791179
* @param tok pointer to start of statement
11801180
* @param varaccess access control of statement
1181-
* @param settings Settings
11821181
* @return pointer to last token
11831182
*/
1184-
const Token *checkVariable(const Token *tok, AccessControl varaccess, const Settings& settings);
1183+
const Token *checkVariable(const Token *tok, AccessControl varaccess);
11851184

11861185
/**
11871186
* @brief get variable from name

0 commit comments

Comments
 (0)