@@ -140,7 +140,7 @@ const Token* SymbolDatabase::isEnumDefinition(const Token* tok)
140
140
void SymbolDatabase::createSymbolDatabaseFindAllScopes ()
141
141
{
142
142
// create global scope
143
- scopeList.emplace_back (this , nullptr , nullptr );
143
+ scopeList.emplace_back (* this , nullptr , nullptr );
144
144
145
145
// pointer to current scope
146
146
Scope *scope = &scopeList.back ();
@@ -285,7 +285,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
285
285
scope = new_scope;
286
286
tok = tok2;
287
287
} else {
288
- scopeList.emplace_back (this , tok, scope);
288
+ scopeList.emplace_back (* this , tok, scope);
289
289
new_scope = &scopeList.back ();
290
290
291
291
if (tok->str () == " class" )
@@ -350,7 +350,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
350
350
Token::Match (tok, " namespace %name% %type% (" ) &&
351
351
tok->tokAt (2 )->isUpperCaseName () &&
352
352
Token::simpleMatch (tok->linkAt (3 ), " ) {" )) {
353
- scopeList.emplace_back (this , tok, scope);
353
+ scopeList.emplace_back (* this , tok, scope);
354
354
355
355
Scope *new_scope = &scopeList.back ();
356
356
access[new_scope] = AccessControl::Public;
@@ -426,7 +426,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
426
426
// unnamed struct and union
427
427
else if (tok->isKeyword () && Token::Match (tok, " struct|union {" ) &&
428
428
Token::Match (tok->linkAt (1 ), " } *|&| %name% ;|[|=" )) {
429
- scopeList.emplace_back (this , tok, scope);
429
+ scopeList.emplace_back (* this , tok, scope);
430
430
431
431
Scope *new_scope = &scopeList.back ();
432
432
access[new_scope] = AccessControl::Public;
@@ -468,7 +468,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
468
468
else if (tok->isKeyword () && ((Token::Match (tok, " struct|union {" ) &&
469
469
Token::simpleMatch (tok->linkAt (1 ), " } ;" )) ||
470
470
Token::simpleMatch (tok, " namespace {" ))) {
471
- scopeList.emplace_back (this , tok, scope);
471
+ scopeList.emplace_back (* this , tok, scope);
472
472
473
473
Scope *new_scope = &scopeList.back ();
474
474
access[new_scope] = AccessControl::Public;
@@ -706,27 +706,27 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
706
706
if (tok->isKeyword () && Token::Match (tok, " else|try|do {" )) {
707
707
const Token* tok1 = tok->next ();
708
708
if (tok->str () == " else" )
709
- scopeList.emplace_back (this , tok, scope, Scope::eElse, tok1);
709
+ scopeList.emplace_back (* this , tok, scope, Scope::eElse, tok1);
710
710
else if (tok->str () == " do" )
711
- scopeList.emplace_back (this , tok, scope, Scope::eDo, tok1);
711
+ scopeList.emplace_back (* this , tok, scope, Scope::eDo, tok1);
712
712
else // if (tok->str() == "try")
713
- scopeList.emplace_back (this , tok, scope, Scope::eTry, tok1);
713
+ scopeList.emplace_back (* this , tok, scope, Scope::eTry, tok1);
714
714
715
715
tok = tok1;
716
716
scope->nestedList .push_back (&scopeList.back ());
717
717
scope = &scopeList.back ();
718
718
} else if (tok->isKeyword () && Token::Match (tok, " if|for|while|catch|switch (" ) && Token::simpleMatch (tok->linkAt (1 ), " ) {" )) {
719
719
const Token *scopeStartTok = tok->linkAt (1 )->next ();
720
720
if (tok->str () == " if" )
721
- scopeList.emplace_back (this , tok, scope, Scope::eIf, scopeStartTok);
721
+ scopeList.emplace_back (* this , tok, scope, Scope::eIf, scopeStartTok);
722
722
else if (tok->str () == " for" ) {
723
- scopeList.emplace_back (this , tok, scope, Scope::eFor, scopeStartTok);
723
+ scopeList.emplace_back (* this , tok, scope, Scope::eFor, scopeStartTok);
724
724
} else if (tok->str () == " while" )
725
- scopeList.emplace_back (this , tok, scope, Scope::eWhile, scopeStartTok);
725
+ scopeList.emplace_back (* this , tok, scope, Scope::eWhile, scopeStartTok);
726
726
else if (tok->str () == " catch" ) {
727
- scopeList.emplace_back (this , tok, scope, Scope::eCatch, scopeStartTok);
727
+ scopeList.emplace_back (* this , tok, scope, Scope::eCatch, scopeStartTok);
728
728
} else // if (tok->str() == "switch")
729
- scopeList.emplace_back (this , tok, scope, Scope::eSwitch, scopeStartTok);
729
+ scopeList.emplace_back (* this , tok, scope, Scope::eSwitch, scopeStartTok);
730
730
731
731
scope->nestedList .push_back (&scopeList.back ());
732
732
scope = &scopeList.back ();
@@ -747,7 +747,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
747
747
} else if (!inIfCondition.empty () && tok == inIfCondition.top ()) {
748
748
inIfCondition.pop ();
749
749
} else if (isExecutableScope (tok)) {
750
- scopeList.emplace_back (this , tok, scope, Scope::eUnconditional, tok);
750
+ scopeList.emplace_back (* this , tok, scope, Scope::eUnconditional, tok);
751
751
scope->nestedList .push_back (&scopeList.back ());
752
752
scope = &scopeList.back ();
753
753
} else {
@@ -2789,10 +2789,10 @@ static bool typesMatch(
2789
2789
const Token *&new_second)
2790
2790
{
2791
2791
// get first type
2792
- const Type* first_type = first_scope->symdb -> findType (first_token, first_scope, /* lookOutside*/ true );
2792
+ const Type* first_type = first_scope->symdb . findType (first_token, first_scope, /* lookOutside*/ true );
2793
2793
if (first_type) {
2794
2794
// get second type
2795
- const Type* second_type = second_scope->symdb -> findType (second_token, second_scope, /* lookOutside*/ true );
2795
+ const Type* second_type = second_scope->symdb . findType (second_token, second_scope, /* lookOutside*/ true );
2796
2796
// check if types match
2797
2797
if (first_type == second_type) {
2798
2798
const Token* tok1 = first_token;
@@ -3438,7 +3438,7 @@ void SymbolDatabase::addClassFunction(Scope *&scope, const Token *&tok, const To
3438
3438
void SymbolDatabase::addNewFunction (Scope *&scope, const Token *&tok)
3439
3439
{
3440
3440
const Token *tok1 = tok;
3441
- scopeList.emplace_back (this , tok1, scope);
3441
+ scopeList.emplace_back (* this , tok1, scope);
3442
3442
Scope *newScope = &scopeList.back ();
3443
3443
3444
3444
// find start of function '{'
@@ -3566,7 +3566,7 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1)
3566
3566
}
3567
3567
}
3568
3568
3569
- const Type * baseType = classScope->symdb -> findType (base.nameTok , enclosingScope);
3569
+ const Type * baseType = classScope->symdb . findType (base.nameTok , enclosingScope);
3570
3570
if (baseType && !baseType->findDependency (this ))
3571
3571
base.type = baseType;
3572
3572
@@ -4414,15 +4414,15 @@ void SymbolDatabase::printXml(std::ostream &out) const
4414
4414
4415
4415
static const Type* findVariableTypeIncludingUsedNamespaces (const Scope* scope, const Token* typeTok)
4416
4416
{
4417
- const Type* argType = scope->symdb -> findVariableType (scope, typeTok);
4417
+ const Type* argType = scope->symdb . findVariableType (scope, typeTok);
4418
4418
if (argType)
4419
4419
return argType;
4420
4420
4421
4421
// look for variable type in any using namespace in this scope or above
4422
4422
while (scope) {
4423
4423
for (const Scope::UsingInfo &ui : scope->usingList ) {
4424
4424
if (ui.scope ) {
4425
- argType = scope->symdb -> findVariableType (ui.scope , typeTok);
4425
+ argType = scope->symdb . findVariableType (ui.scope , typeTok);
4426
4426
if (argType)
4427
4427
return argType;
4428
4428
}
@@ -4495,7 +4495,7 @@ void Function::addArguments(const Scope *scope)
4495
4495
while (Token::Match (typeTok, " const|volatile|enum|struct|::" ))
4496
4496
typeTok = typeTok->next ();
4497
4497
if (Token::Match (typeTok, " ,|)" )) { // #8333
4498
- scope->symdb -> mTokenizer .syntaxError (typeTok);
4498
+ scope->symdb . mTokenizer .syntaxError (typeTok);
4499
4499
}
4500
4500
if (Token::Match (typeTok, " %type% <" ) && Token::Match (typeTok->linkAt (1 ), " > :: %type%" ))
4501
4501
typeTok = typeTok->linkAt (1 )->tokAt (2 );
@@ -4514,7 +4514,7 @@ void Function::addArguments(const Scope *scope)
4514
4514
endTok = nameTok->previous ();
4515
4515
4516
4516
if (hasBody ())
4517
- scope->symdb -> debugMessage (nameTok, " varid0" , " Function::addArguments found argument \' " + nameTok->str () + " \' with varid 0." );
4517
+ scope->symdb . debugMessage (nameTok, " varid0" , " Function::addArguments found argument \' " + nameTok->str () + " \' with varid 0." );
4518
4518
} else
4519
4519
endTok = typeTok;
4520
4520
} else
@@ -4545,7 +4545,7 @@ void Function::addArguments(const Scope *scope)
4545
4545
if (startTok == nameTok)
4546
4546
break ;
4547
4547
4548
- argumentList.emplace_back (nameTok, startTok, endTok, count++, AccessControl::Argument, argType, functionScope, scope->symdb -> mTokenizer .getSettings ());
4548
+ argumentList.emplace_back (nameTok, startTok, endTok, count++, AccessControl::Argument, argType, functionScope, scope->symdb . mTokenizer .getSettings ());
4549
4549
4550
4550
if (tok->str () == " )" ) {
4551
4551
// check for a variadic function or a variadic template function
@@ -4716,23 +4716,20 @@ const Variable* Function::getArgumentVar(nonneg int num) const
4716
4716
4717
4717
// ---------------------------------------------------------------------------
4718
4718
4719
- Scope::Scope (const SymbolDatabase * symdb_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_) :
4719
+ Scope::Scope (const SymbolDatabase & symdb_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_) :
4720
4720
symdb(symdb_),
4721
4721
classDef(classDef_),
4722
4722
nestedIn(nestedIn_),
4723
4723
type(type_)
4724
4724
{
4725
- assert (symdb_);
4726
4725
setBodyStartEnd (start_);
4727
4726
}
4728
4727
4729
- Scope::Scope (const SymbolDatabase * symdb_, const Token *classDef_, const Scope *nestedIn_) :
4728
+ Scope::Scope (const SymbolDatabase & symdb_, const Token *classDef_, const Scope *nestedIn_) :
4730
4729
symdb(symdb_),
4731
4730
classDef(classDef_),
4732
4731
nestedIn(nestedIn_)
4733
4732
{
4734
- assert (symdb_);
4735
-
4736
4733
const Token *nameTok = classDef;
4737
4734
if (!classDef) {
4738
4735
type = Scope::eGlobal;
@@ -4790,7 +4787,7 @@ void Scope::addVariable(const Token *token_, const Token *start_, const Token *e
4790
4787
// keep possible size_t -> int truncation outside emplace_back() to have a single line
4791
4788
// C4267 VC++ warning instead of several dozens lines
4792
4789
const int varIndex = varlist.size ();
4793
- varlist.emplace_back (token_, start_, end_, varIndex, access_, type_, scope_, scope_->symdb -> mTokenizer .getSettings ());
4790
+ varlist.emplace_back (token_, start_, end_, varIndex, access_, type_, scope_, scope_->symdb . mTokenizer .getSettings ());
4794
4791
}
4795
4792
4796
4793
// Get variable list..
@@ -4803,7 +4800,7 @@ void Scope::getVariableList()
4803
4800
4804
4801
// global scope
4805
4802
else if (type == Scope::eGlobal)
4806
- getVariableList (symdb-> mTokenizer .tokens (), nullptr );
4803
+ getVariableList (symdb. mTokenizer .tokens (), nullptr );
4807
4804
4808
4805
// forward declaration
4809
4806
else
@@ -4948,7 +4945,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess)
4948
4945
const Token *typestart = tok;
4949
4946
4950
4947
// C++17 structured bindings
4951
- if (tok && tok->isCpp () && (symdb-> mTokenizer .getSettings ().standards .cpp >= Standards::CPP17) && Token::Match (tok, " auto &|&&| [" )) {
4948
+ if (tok && tok->isCpp () && (symdb. mTokenizer .getSettings ().standards .cpp >= Standards::CPP17) && Token::Match (tok, " auto &|&&| [" )) {
4952
4949
const Token *typeend = Token::findsimplematch (typestart, " [" )->previous ();
4953
4950
for (tok = typeend->tokAt (2 ); Token::Match (tok, " %name%|," ); tok = tok->next ()) {
4954
4951
if (tok->varId ())
@@ -4973,7 +4970,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess)
4973
4970
4974
4971
if (vartok->varId () == 0 ) {
4975
4972
if (!vartok->isBoolean ())
4976
- symdb-> 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." );
4977
4974
return tok;
4978
4975
}
4979
4976
@@ -5053,7 +5050,7 @@ bool Scope::isVariableDeclaration(const Token* const tok, const Token*& vartok,
5053
5050
if (isCPP && Token::Match (tok, " throw|new" ))
5054
5051
return false ;
5055
5052
5056
- const bool isCPP11 = isCPP && symdb-> mTokenizer .getSettings ().standards .cpp >= Standards::CPP11;
5053
+ const bool isCPP11 = isCPP && symdb. mTokenizer .getSettings ().standards .cpp >= Standards::CPP11;
5057
5054
5058
5055
if (isCPP11 && tok->str () == " using" )
5059
5056
return false ;
@@ -7249,7 +7246,7 @@ static const Token* parsedecl(const Token* type,
7249
7246
valuetype->container = container;
7250
7247
} else {
7251
7248
const Scope *scope = type->scope ();
7252
- valuetype->typeScope = scope->symdb -> findScope (typeTokens.front (), scope);
7249
+ valuetype->typeScope = scope->symdb . findScope (typeTokens.front (), scope);
7253
7250
if (valuetype->typeScope )
7254
7251
valuetype->type = (scope->type == Scope::ScopeType::eClass) ? ValueType::Type::RECORD : ValueType::Type::NONSTD;
7255
7252
}
0 commit comments