@@ -227,8 +227,13 @@ namespace clangimport {
227227 Variable* var{};
228228 };
229229
230- const Settings *mSettings = nullptr ;
231- SymbolDatabase *mSymbolDatabase = nullptr ;
230+ Data (const Settings& settings, SymbolDatabase& symbolDatabase)
231+ : mSettings (settings)
232+ , mSymbolDatabase (symbolDatabase)
233+ {}
234+
235+ const Settings &mSettings ;
236+ SymbolDatabase &mSymbolDatabase ;
232237
233238 int enumValue = 0 ;
234239
@@ -657,7 +662,7 @@ void clangimport::AstNode::addFullScopeNameTokens(TokenList &tokenList, const Sc
657662const Scope *clangimport::AstNode::getNestedInScope (TokenList &tokenList)
658663{
659664 if (!tokenList.back ())
660- return &mData ->mSymbolDatabase -> scopeList .front ();
665+ return &mData ->mSymbolDatabase . scopeList .front ();
661666 if (tokenList.back ()->str () == " }" && mData ->mNotScope .find (tokenList.back ()) == mData ->mNotScope .end ())
662667 return tokenList.back ()->scope ()->nestedIn ;
663668 return tokenList.back ()->scope ();
@@ -678,7 +683,7 @@ void clangimport::AstNode::setValueType(Token *tok)
678683 if (!decl.front ())
679684 break ;
680685
681- ValueType valueType = ValueType::parseDecl (decl.front (), * mData ->mSettings );
686+ ValueType valueType = ValueType::parseDecl (decl.front (), mData ->mSettings );
682687 if (valueType.type != ValueType::Type::UNKNOWN_TYPE) {
683688 tok->setValueType (new ValueType (std::move (valueType)));
684689 break ;
@@ -694,12 +699,12 @@ Scope *clangimport::AstNode::createScope(TokenList &tokenList, ScopeType scopeTy
694699
695700Scope *clangimport::AstNode::createScope (TokenList &tokenList, ScopeType scopeType, const std::vector<AstNodePtr> & children2, const Token *def)
696701{
697- SymbolDatabase * symbolDatabase = mData ->mSymbolDatabase ;
702+ SymbolDatabase & symbolDatabase = mData ->mSymbolDatabase ;
698703
699704 auto *nestedIn = const_cast <Scope *>(getNestedInScope (tokenList));
700705
701- symbolDatabase-> scopeList .emplace_back (nullptr , nullptr , nestedIn);
702- Scope *scope = &symbolDatabase-> scopeList .back ();
706+ symbolDatabase. scopeList .emplace_back (nullptr , nullptr , nestedIn);
707+ Scope *scope = &symbolDatabase. scopeList .back ();
703708 if (scopeType == ScopeType::eEnum)
704709 scope->enumeratorList .reserve (children2.size ());
705710 nestedIn->nestedList .push_back (scope);
@@ -1058,8 +1063,8 @@ Token *clangimport::AstNode::createTokens(TokenList &tokenList)
10581063 const_cast <Token *>(enumscope->bodyEnd )->deletePrevious ();
10591064
10601065 // Create enum type
1061- mData ->mSymbolDatabase -> typeList .emplace_back (enumtok, enumscope, enumtok->scope ());
1062- enumscope->definedType = &mData ->mSymbolDatabase -> typeList .back ();
1066+ mData ->mSymbolDatabase . typeList .emplace_back (enumtok, enumscope, enumtok->scope ());
1067+ enumscope->definedType = &mData ->mSymbolDatabase . typeList .back ();
10631068 if (nametok)
10641069 const_cast <Scope *>(enumtok->scope ())->definedTypesMap [nametok->str ()] = enumscope->definedType ;
10651070
@@ -1225,8 +1230,8 @@ Token *clangimport::AstNode::createTokens(TokenList &tokenList)
12251230 }
12261231
12271232 Scope *recordScope = createScope (tokenList, ScopeType::eStruct, children, classDef);
1228- mData ->mSymbolDatabase -> typeList .emplace_back (classDef, recordScope, classDef->scope ());
1229- recordScope->definedType = &mData ->mSymbolDatabase -> typeList .back ();
1233+ mData ->mSymbolDatabase . typeList .emplace_back (classDef, recordScope, classDef->scope ());
1234+ recordScope->definedType = &mData ->mSymbolDatabase . typeList .back ();
12301235 if (!recordName.empty ()) {
12311236 recordScope->className = recordName;
12321237 const_cast <Scope *>(classDef->scope ())->definedTypesMap [recordName] = recordScope->definedType ;
@@ -1358,7 +1363,7 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList &tokenList)
13581363
13591364 const Token *startToken = nullptr ;
13601365
1361- SymbolDatabase * symbolDatabase = mData ->mSymbolDatabase ;
1366+ SymbolDatabase & symbolDatabase = mData ->mSymbolDatabase ;
13621367 if (nodeType != CXXConstructorDecl && nodeType != CXXDestructorDecl) {
13631368 if (isStatic)
13641369 addtoken (tokenList, " static" );
@@ -1400,9 +1405,9 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList &tokenList)
14001405
14011406 Scope *scope = nullptr ;
14021407 if (hasBody) {
1403- symbolDatabase-> scopeList .emplace_back (nullptr , nullptr , nestedIn);
1404- scope = &symbolDatabase-> scopeList .back ();
1405- scope->check = symbolDatabase;
1408+ symbolDatabase. scopeList .emplace_back (nullptr , nullptr , nestedIn);
1409+ scope = &symbolDatabase. scopeList .back ();
1410+ scope->check = & symbolDatabase;
14061411 scope->function = function;
14071412 scope->classDef = nameToken;
14081413 scope->type = ScopeType::eFunction;
@@ -1452,7 +1457,7 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList &tokenList)
14521457
14531458 // Function body
14541459 if (hasBody) {
1455- symbolDatabase-> functionScopes .push_back (scope);
1460+ symbolDatabase. functionScopes .push_back (scope);
14561461 Token *bodyStart = addtoken (tokenList, " {" );
14571462 bodyStart->scope (scope);
14581463 children.back ()->createTokens (tokenList);
@@ -1508,8 +1513,8 @@ void clangimport::AstNode::createTokensForCXXRecord(TokenList &tokenList)
15081513 const std::string addr = mExtTokens [0 ];
15091514 mData ->scopeDecl (addr, scope);
15101515 scope->className = className;
1511- mData ->mSymbolDatabase -> typeList .emplace_back (classToken, scope, classToken->scope ());
1512- scope->definedType = &mData ->mSymbolDatabase -> typeList .back ();
1516+ mData ->mSymbolDatabase . typeList .emplace_back (classToken, scope, classToken->scope ());
1517+ scope->definedType = &mData ->mSymbolDatabase . typeList .back ();
15131518 const_cast <Scope *>(classToken->scope ())->definedTypesMap [className] = scope->definedType ;
15141519 }
15151520 addtoken (tokenList, " ;" );
@@ -1620,9 +1625,7 @@ void clangimport::parseClangAstDump(Tokenizer &tokenizer, std::istream &f)
16201625 symbolDatabase->scopeList .back ().type = ScopeType::eGlobal;
16211626 symbolDatabase->scopeList .back ().check = symbolDatabase;
16221627
1623- clangimport::Data data;
1624- data.mSettings = &tokenizer.getSettings ();
1625- data.mSymbolDatabase = symbolDatabase;
1628+ clangimport::Data data (tokenizer.getSettings (), *symbolDatabase);
16261629 std::string line;
16271630 std::vector<AstNodePtr> tree;
16281631 while (std::getline (f,line)) {
0 commit comments