Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SymbolDatabase: do not store references to Settings and ErrorLogger / some related parameter passing cleanups #7050

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
15 changes: 6 additions & 9 deletions lib/clangimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ const ::Type * clangimport::AstNode::addTypeTokens(TokenList &tokenList, const s
for (const Token *typeToken = tokenList.back(); Token::Match(typeToken, "&|*|%name%"); typeToken = typeToken->previous()) {
if (!typeToken->isName())
continue;
const ::Type *recordType = scope->check->findVariableType(scope, typeToken);
const ::Type *recordType = scope->symdb.findVariableType(scope, typeToken);
if (recordType) {
const_cast<Token*>(typeToken)->type(recordType);
return recordType;
Expand Down Expand Up @@ -698,14 +698,13 @@ Scope *clangimport::AstNode::createScope(TokenList &tokenList, Scope::ScopeType

auto *nestedIn = const_cast<Scope *>(getNestedInScope(tokenList));

symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nestedIn);
symbolDatabase->scopeList.emplace_back(nestedIn->symdb, nullptr, nestedIn);
Scope *scope = &symbolDatabase->scopeList.back();
if (scopeType == Scope::ScopeType::eEnum)
scope->enumeratorList.reserve(children2.size());
nestedIn->nestedList.push_back(scope);
scope->type = scopeType;
scope->classDef = def;
scope->check = nestedIn->check;
scope->classDef = def; // TODO: pass into ctor
if (Token::Match(def, "if|for|while (")) {
std::map<const Variable *, const Variable *> replaceVar;
for (const Token *vartok = def->tokAt(2); vartok; vartok = vartok->next()) {
Expand Down Expand Up @@ -1401,11 +1400,10 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList &tokenList)

Scope *scope = nullptr;
if (hasBody) {
symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nestedIn);
symbolDatabase->scopeList.emplace_back(*symbolDatabase, nullptr, nestedIn);
scope = &symbolDatabase->scopeList.back();
scope->check = symbolDatabase;
scope->function = function;
scope->classDef = nameToken;
scope->classDef = nameToken; // TODO: pass into ctor
scope->type = Scope::ScopeType::eFunction;
scope->className = nameToken->str();
nestedIn->nestedList.push_back(scope);
Expand Down Expand Up @@ -1617,9 +1615,8 @@ void clangimport::parseClangAstDump(Tokenizer &tokenizer, std::istream &f)

tokenizer.createSymbolDatabase();
auto *symbolDatabase = const_cast<SymbolDatabase *>(tokenizer.getSymbolDatabase());
symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nullptr);
symbolDatabase->scopeList.emplace_back(*symbolDatabase, nullptr, nullptr);
symbolDatabase->scopeList.back().type = Scope::ScopeType::eGlobal;
symbolDatabase->scopeList.back().check = symbolDatabase;

clangimport::Data data;
data.mSettings = &tokenizer.getSettings();
Expand Down
Loading
Loading