@@ -227,8 +227,13 @@ namespace clangimport {
227
227
Variable* var{};
228
228
};
229
229
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 ;
232
237
233
238
int enumValue = 0 ;
234
239
@@ -657,7 +662,7 @@ void clangimport::AstNode::addFullScopeNameTokens(TokenList &tokenList, const Sc
657
662
const Scope *clangimport::AstNode::getNestedInScope (TokenList &tokenList)
658
663
{
659
664
if (!tokenList.back ())
660
- return &mData ->mSymbolDatabase -> scopeList .front ();
665
+ return &mData ->mSymbolDatabase . scopeList .front ();
661
666
if (tokenList.back ()->str () == " }" && mData ->mNotScope .find (tokenList.back ()) == mData ->mNotScope .end ())
662
667
return tokenList.back ()->scope ()->nestedIn ;
663
668
return tokenList.back ()->scope ();
@@ -678,7 +683,7 @@ void clangimport::AstNode::setValueType(Token *tok)
678
683
if (!decl.front ())
679
684
break ;
680
685
681
- ValueType valueType = ValueType::parseDecl (decl.front (), * mData ->mSettings );
686
+ ValueType valueType = ValueType::parseDecl (decl.front (), mData ->mSettings );
682
687
if (valueType.type != ValueType::Type::UNKNOWN_TYPE) {
683
688
tok->setValueType (new ValueType (std::move (valueType)));
684
689
break ;
@@ -694,12 +699,12 @@ Scope *clangimport::AstNode::createScope(TokenList &tokenList, ScopeType scopeTy
694
699
695
700
Scope *clangimport::AstNode::createScope (TokenList &tokenList, ScopeType scopeType, const std::vector<AstNodePtr> & children2, const Token *def)
696
701
{
697
- SymbolDatabase * symbolDatabase = mData ->mSymbolDatabase ;
702
+ SymbolDatabase & symbolDatabase = mData ->mSymbolDatabase ;
698
703
699
704
auto *nestedIn = const_cast <Scope *>(getNestedInScope (tokenList));
700
705
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 ();
703
708
if (scopeType == ScopeType::eEnum)
704
709
scope->enumeratorList .reserve (children2.size ());
705
710
nestedIn->nestedList .push_back (scope);
@@ -1058,8 +1063,8 @@ Token *clangimport::AstNode::createTokens(TokenList &tokenList)
1058
1063
const_cast <Token *>(enumscope->bodyEnd )->deletePrevious ();
1059
1064
1060
1065
// 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 ();
1063
1068
if (nametok)
1064
1069
const_cast <Scope *>(enumtok->scope ())->definedTypesMap [nametok->str ()] = enumscope->definedType ;
1065
1070
@@ -1225,8 +1230,8 @@ Token *clangimport::AstNode::createTokens(TokenList &tokenList)
1225
1230
}
1226
1231
1227
1232
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 ();
1230
1235
if (!recordName.empty ()) {
1231
1236
recordScope->className = recordName;
1232
1237
const_cast <Scope *>(classDef->scope ())->definedTypesMap [recordName] = recordScope->definedType ;
@@ -1358,7 +1363,7 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList &tokenList)
1358
1363
1359
1364
const Token *startToken = nullptr ;
1360
1365
1361
- SymbolDatabase * symbolDatabase = mData ->mSymbolDatabase ;
1366
+ SymbolDatabase & symbolDatabase = mData ->mSymbolDatabase ;
1362
1367
if (nodeType != CXXConstructorDecl && nodeType != CXXDestructorDecl) {
1363
1368
if (isStatic)
1364
1369
addtoken (tokenList, " static" );
@@ -1400,9 +1405,9 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList &tokenList)
1400
1405
1401
1406
Scope *scope = nullptr ;
1402
1407
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;
1406
1411
scope->function = function;
1407
1412
scope->classDef = nameToken;
1408
1413
scope->type = ScopeType::eFunction;
@@ -1452,7 +1457,7 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList &tokenList)
1452
1457
1453
1458
// Function body
1454
1459
if (hasBody) {
1455
- symbolDatabase-> functionScopes .push_back (scope);
1460
+ symbolDatabase. functionScopes .push_back (scope);
1456
1461
Token *bodyStart = addtoken (tokenList, " {" );
1457
1462
bodyStart->scope (scope);
1458
1463
children.back ()->createTokens (tokenList);
@@ -1508,8 +1513,8 @@ void clangimport::AstNode::createTokensForCXXRecord(TokenList &tokenList)
1508
1513
const std::string addr = mExtTokens [0 ];
1509
1514
mData ->scopeDecl (addr, scope);
1510
1515
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 ();
1513
1518
const_cast <Scope *>(classToken->scope ())->definedTypesMap [className] = scope->definedType ;
1514
1519
}
1515
1520
addtoken (tokenList, " ;" );
@@ -1620,9 +1625,7 @@ void clangimport::parseClangAstDump(Tokenizer &tokenizer, std::istream &f)
1620
1625
symbolDatabase->scopeList .back ().type = ScopeType::eGlobal;
1621
1626
symbolDatabase->scopeList .back ().check = symbolDatabase;
1622
1627
1623
- clangimport::Data data;
1624
- data.mSettings = &tokenizer.getSettings ();
1625
- data.mSymbolDatabase = symbolDatabase;
1628
+ clangimport::Data data (tokenizer.getSettings (), *symbolDatabase);
1626
1629
std::string line;
1627
1630
std::vector<AstNodePtr> tree;
1628
1631
while (std::getline (f,line)) {
0 commit comments