Skip to content

Commit 49377d4

Browse files
committed
Scope: renamed check to symdb
1 parent 164e064 commit 49377d4

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

lib/clangimport.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ const ::Type * clangimport::AstNode::addTypeTokens(TokenList &tokenList, const s
588588
for (const Token *typeToken = tokenList.back(); Token::Match(typeToken, "&|*|%name%"); typeToken = typeToken->previous()) {
589589
if (!typeToken->isName())
590590
continue;
591-
const ::Type *recordType = scope->check->findVariableType(scope, typeToken);
591+
const ::Type *recordType = scope->symdb->findVariableType(scope, typeToken);
592592
if (recordType) {
593593
const_cast<Token*>(typeToken)->type(recordType);
594594
return recordType;
@@ -665,7 +665,7 @@ Scope *clangimport::AstNode::createScope(TokenList &tokenList, Scope::ScopeType
665665
nestedIn->nestedList.push_back(scope);
666666
scope->type = scopeType;
667667
scope->classDef = def;
668-
scope->check = nestedIn->check;
668+
scope->symdb = nestedIn->symdb;
669669
if (Token::Match(def, "if|for|while (")) {
670670
std::map<const Variable *, const Variable *> replaceVar;
671671
for (const Token *vartok = def->tokAt(2); vartok; vartok = vartok->next()) {
@@ -1363,7 +1363,7 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList &tokenList)
13631363
if (hasBody) {
13641364
symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nestedIn);
13651365
scope = &symbolDatabase->scopeList.back();
1366-
scope->check = symbolDatabase;
1366+
scope->symdb = symbolDatabase;
13671367
scope->function = function;
13681368
scope->classDef = nameToken;
13691369
scope->type = Scope::ScopeType::eFunction;
@@ -1579,7 +1579,7 @@ void clangimport::parseClangAstDump(Tokenizer &tokenizer, std::istream &f)
15791579
auto *symbolDatabase = const_cast<SymbolDatabase *>(tokenizer.getSymbolDatabase());
15801580
symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nullptr);
15811581
symbolDatabase->scopeList.back().type = Scope::ScopeType::eGlobal;
1582-
symbolDatabase->scopeList.back().check = symbolDatabase;
1582+
symbolDatabase->scopeList.back().symdb = symbolDatabase;
15831583

15841584
clangimport::Data data;
15851585
data.mSettings = &tokenizer.getSettings();

lib/symboldatabase.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -2789,10 +2789,10 @@ static bool typesMatch(
27892789
const Token *&new_second)
27902790
{
27912791
// get first type
2792-
const Type* first_type = first_scope->check->findType(first_token, first_scope, /*lookOutside*/ true);
2792+
const Type* first_type = first_scope->symdb->findType(first_token, first_scope, /*lookOutside*/ true);
27932793
if (first_type) {
27942794
// get second type
2795-
const Type* second_type = second_scope->check->findType(second_token, second_scope, /*lookOutside*/ true);
2795+
const Type* second_type = second_scope->symdb->findType(second_token, second_scope, /*lookOutside*/ true);
27962796
// check if types match
27972797
if (first_type == second_type) {
27982798
const Token* tok1 = first_token;
@@ -3566,7 +3566,7 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1)
35663566
}
35673567
}
35683568

3569-
const Type * baseType = classScope->check->findType(base.nameTok, enclosingScope);
3569+
const Type * baseType = classScope->symdb->findType(base.nameTok, enclosingScope);
35703570
if (baseType && !baseType->findDependency(this))
35713571
base.type = baseType;
35723572

@@ -4716,17 +4716,17 @@ const Variable* Function::getArgumentVar(nonneg int num) const
47164716

47174717
//---------------------------------------------------------------------------
47184718

4719-
Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_) :
4720-
check(check_),
4719+
Scope::Scope(const SymbolDatabase *symdb_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_) :
4720+
symdb(symdb_),
47214721
classDef(classDef_),
47224722
nestedIn(nestedIn_),
47234723
type(type_)
47244724
{
47254725
setBodyStartEnd(start_);
47264726
}
47274727

4728-
Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_) :
4729-
check(check_),
4728+
Scope::Scope(const SymbolDatabase *symdb_, const Token *classDef_, const Scope *nestedIn_) :
4729+
symdb(symdb_),
47304730
classDef(classDef_),
47314731
nestedIn(nestedIn_)
47324732
{
@@ -4800,7 +4800,7 @@ void Scope::getVariableList(const Settings& settings)
48004800

48014801
// global scope
48024802
else if (type == Scope::eGlobal)
4803-
getVariableList(settings, check->mTokenizer.tokens(), nullptr);
4803+
getVariableList(settings, symdb->mTokenizer.tokens(), nullptr);
48044804

48054805
// forward declaration
48064806
else
@@ -4970,14 +4970,14 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con
49704970

49714971
if (vartok->varId() == 0) {
49724972
if (!vartok->isBoolean())
4973-
check->debugMessage(vartok, "varid0", "Scope::checkVariable found variable \'" + vartok->str() + "\' with varid 0.");
4973+
symdb->debugMessage(vartok, "varid0", "Scope::checkVariable found variable \'" + vartok->str() + "\' with varid 0.");
49744974
return tok;
49754975
}
49764976

49774977
const Type *vType = nullptr;
49784978

49794979
if (typetok) {
4980-
vType = findVariableTypeIncludingUsedNamespaces(check, this, typetok);
4980+
vType = findVariableTypeIncludingUsedNamespaces(symdb, this, typetok);
49814981

49824982
const_cast<Token *>(typetok)->type(vType);
49834983
}
@@ -5050,7 +5050,7 @@ bool Scope::isVariableDeclaration(const Token* const tok, const Token*& vartok,
50505050
if (isCPP && Token::Match(tok, "throw|new"))
50515051
return false;
50525052

5053-
const bool isCPP11 = isCPP && check->mSettings.standards.cpp >= Standards::CPP11;
5053+
const bool isCPP11 = isCPP && symdb->mSettings.standards.cpp >= Standards::CPP11;
50545054

50555055
if (isCPP11 && tok->str() == "using")
50565056
return false;
@@ -7246,7 +7246,7 @@ static const Token* parsedecl(const Token* type,
72467246
valuetype->container = container;
72477247
} else {
72487248
const Scope *scope = type->scope();
7249-
valuetype->typeScope = scope->check->findScope(typeTokens.front(), scope);
7249+
valuetype->typeScope = scope->symdb->findScope(typeTokens.front(), scope);
72507250
if (valuetype->typeScope)
72517251
valuetype->type = (scope->type == Scope::ScopeType::eClass) ? ValueType::Type::RECORD : ValueType::Type::NONSTD;
72527252
}

lib/symboldatabase.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1030,10 +1030,10 @@ class CPPCHECKLIB Scope {
10301030

10311031
enum ScopeType : std::uint8_t { eGlobal, eClass, eStruct, eUnion, eNamespace, eFunction, eIf, eElse, eFor, eWhile, eDo, eSwitch, eUnconditional, eTry, eCatch, eLambda, eEnum };
10321032

1033-
Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_);
1034-
Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_);
1033+
Scope(const SymbolDatabase *symdb_, const Token *classDef_, const Scope *nestedIn_);
1034+
Scope(const SymbolDatabase *symdb_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_);
10351035

1036-
const SymbolDatabase* check{};
1036+
const SymbolDatabase* symdb{};
10371037
std::string className;
10381038
const Token* classDef{}; ///< class/struct/union/namespace token
10391039
const Token* bodyStart{}; ///< '{' token

0 commit comments

Comments
 (0)