@@ -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 {
@@ -2787,10 +2787,10 @@ static bool typesMatch(
2787
2787
const Token *&new_second)
2788
2788
{
2789
2789
// get first type
2790
- const Type* first_type = first_scope->symdb -> findType (first_token, first_scope, /* lookOutside*/ true );
2790
+ const Type* first_type = first_scope->symdb . findType (first_token, first_scope, /* lookOutside*/ true );
2791
2791
if (first_type) {
2792
2792
// get second type
2793
- const Type* second_type = second_scope->symdb -> findType (second_token, second_scope, /* lookOutside*/ true );
2793
+ const Type* second_type = second_scope->symdb . findType (second_token, second_scope, /* lookOutside*/ true );
2794
2794
// check if types match
2795
2795
if (first_type == second_type) {
2796
2796
const Token* tok1 = first_token;
@@ -3437,7 +3437,7 @@ void SymbolDatabase::addClassFunction(Scope *&scope, const Token *&tok, const To
3437
3437
void SymbolDatabase::addNewFunction (Scope *&scope, const Token *&tok)
3438
3438
{
3439
3439
const Token *tok1 = tok;
3440
- scopeList.emplace_back (this , tok1, scope);
3440
+ scopeList.emplace_back (* this , tok1, scope);
3441
3441
Scope *newScope = &scopeList.back ();
3442
3442
3443
3443
// find start of function '{'
@@ -3565,7 +3565,7 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1)
3565
3565
}
3566
3566
}
3567
3567
3568
- const Type * baseType = classScope->symdb -> findType (base.nameTok , enclosingScope);
3568
+ const Type * baseType = classScope->symdb . findType (base.nameTok , enclosingScope);
3569
3569
if (baseType && !baseType->findDependency (this ))
3570
3570
base.type = baseType;
3571
3571
@@ -4415,15 +4415,15 @@ void SymbolDatabase::printXml(std::ostream &out) const
4415
4415
4416
4416
static const Type* findVariableTypeIncludingUsedNamespaces (const Scope* scope, const Token* typeTok)
4417
4417
{
4418
- const Type* argType = scope->symdb -> findVariableType (scope, typeTok);
4418
+ const Type* argType = scope->symdb . findVariableType (scope, typeTok);
4419
4419
if (argType)
4420
4420
return argType;
4421
4421
4422
4422
// look for variable type in any using namespace in this scope or above
4423
4423
while (scope) {
4424
4424
for (const Scope::UsingInfo &ui : scope->usingList ) {
4425
4425
if (ui.scope ) {
4426
- argType = scope->symdb -> findVariableType (ui.scope , typeTok);
4426
+ argType = scope->symdb . findVariableType (ui.scope , typeTok);
4427
4427
if (argType)
4428
4428
return argType;
4429
4429
}
@@ -4496,7 +4496,7 @@ void Function::addArguments(const Scope *scope)
4496
4496
while (Token::Match (typeTok, " const|volatile|enum|struct|::" ))
4497
4497
typeTok = typeTok->next ();
4498
4498
if (Token::Match (typeTok, " ,|)" )) { // #8333
4499
- scope->symdb -> mTokenizer .syntaxError (typeTok);
4499
+ scope->symdb . mTokenizer .syntaxError (typeTok);
4500
4500
}
4501
4501
if (Token::Match (typeTok, " %type% <" ) && Token::Match (typeTok->linkAt (1 ), " > :: %type%" ))
4502
4502
typeTok = typeTok->linkAt (1 )->tokAt (2 );
@@ -4515,7 +4515,7 @@ void Function::addArguments(const Scope *scope)
4515
4515
endTok = nameTok->previous ();
4516
4516
4517
4517
if (hasBody ())
4518
- scope->symdb -> debugMessage (nameTok, " varid0" , " Function::addArguments found argument \' " + nameTok->str () + " \' with varid 0." );
4518
+ scope->symdb . debugMessage (nameTok, " varid0" , " Function::addArguments found argument \' " + nameTok->str () + " \' with varid 0." );
4519
4519
} else
4520
4520
endTok = typeTok;
4521
4521
} else
@@ -4546,7 +4546,7 @@ void Function::addArguments(const Scope *scope)
4546
4546
if (startTok == nameTok)
4547
4547
break ;
4548
4548
4549
- argumentList.emplace_back (nameTok, startTok, endTok, count++, AccessControl::Argument, argType, functionScope, scope->symdb -> mTokenizer .getSettings ());
4549
+ argumentList.emplace_back (nameTok, startTok, endTok, count++, AccessControl::Argument, argType, functionScope, scope->symdb . mTokenizer .getSettings ());
4550
4550
4551
4551
if (tok->str () == " )" ) {
4552
4552
// check for a variadic function or a variadic template function
@@ -4719,23 +4719,20 @@ const Variable* Function::getArgumentVar(nonneg int num) const
4719
4719
4720
4720
// ---------------------------------------------------------------------------
4721
4721
4722
- Scope::Scope (const SymbolDatabase * symdb_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_) :
4722
+ Scope::Scope (const SymbolDatabase & symdb_, const Token *classDef_, const Scope *nestedIn_, ScopeType type_, const Token *start_) :
4723
4723
symdb(symdb_),
4724
4724
classDef(classDef_),
4725
4725
nestedIn(nestedIn_),
4726
4726
type(type_)
4727
4727
{
4728
- assert (symdb_);
4729
4728
setBodyStartEnd (start_);
4730
4729
}
4731
4730
4732
- Scope::Scope (const SymbolDatabase * symdb_, const Token *classDef_, const Scope *nestedIn_) :
4731
+ Scope::Scope (const SymbolDatabase & symdb_, const Token *classDef_, const Scope *nestedIn_) :
4733
4732
symdb(symdb_),
4734
4733
classDef(classDef_),
4735
4734
nestedIn(nestedIn_)
4736
4735
{
4737
- assert (symdb_);
4738
-
4739
4736
const Token *nameTok = classDef;
4740
4737
if (!classDef) {
4741
4738
type = Scope::eGlobal;
@@ -4793,7 +4790,7 @@ void Scope::addVariable(const Token *token_, const Token *start_, const Token *e
4793
4790
// keep possible size_t -> int truncation outside emplace_back() to have a single line
4794
4791
// C4267 VC++ warning instead of several dozens lines
4795
4792
const int varIndex = varlist.size ();
4796
- varlist.emplace_back (token_, start_, end_, varIndex, access_, type_, scope_, scope_->symdb -> mTokenizer .getSettings ());
4793
+ varlist.emplace_back (token_, start_, end_, varIndex, access_, type_, scope_, scope_->symdb . mTokenizer .getSettings ());
4797
4794
}
4798
4795
4799
4796
// Get variable list..
@@ -4806,7 +4803,7 @@ void Scope::getVariableList()
4806
4803
4807
4804
// global scope
4808
4805
else if (type == Scope::eGlobal)
4809
- getVariableList (symdb-> mTokenizer .tokens (), nullptr );
4806
+ getVariableList (symdb. mTokenizer .tokens (), nullptr );
4810
4807
4811
4808
// forward declaration
4812
4809
else
@@ -4951,7 +4948,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess)
4951
4948
const Token *typestart = tok;
4952
4949
4953
4950
// C++17 structured bindings
4954
- if (tok && tok->isCpp () && (symdb-> mTokenizer .getSettings ().standards .cpp >= Standards::CPP17) && Token::Match (tok, " auto &|&&| [" )) {
4951
+ if (tok && tok->isCpp () && (symdb. mTokenizer .getSettings ().standards .cpp >= Standards::CPP17) && Token::Match (tok, " auto &|&&| [" )) {
4955
4952
const Token *typeend = Token::findsimplematch (typestart, " [" )->previous ();
4956
4953
for (tok = typeend->tokAt (2 ); Token::Match (tok, " %name%|," ); tok = tok->next ()) {
4957
4954
if (tok->varId ())
@@ -4976,7 +4973,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess)
4976
4973
4977
4974
if (vartok->varId () == 0 ) {
4978
4975
if (!vartok->isBoolean ())
4979
- symdb-> debugMessage (vartok, " varid0" , " Scope::checkVariable found variable \' " + vartok->str () + " \' with varid 0." );
4976
+ symdb. debugMessage (vartok, " varid0" , " Scope::checkVariable found variable \' " + vartok->str () + " \' with varid 0." );
4980
4977
return tok;
4981
4978
}
4982
4979
@@ -5056,7 +5053,7 @@ bool Scope::isVariableDeclaration(const Token* const tok, const Token*& vartok,
5056
5053
if (isCPP && Token::Match (tok, " throw|new" ))
5057
5054
return false ;
5058
5055
5059
- const bool isCPP11 = isCPP && symdb-> mTokenizer .getSettings ().standards .cpp >= Standards::CPP11;
5056
+ const bool isCPP11 = isCPP && symdb. mTokenizer .getSettings ().standards .cpp >= Standards::CPP11;
5060
5057
5061
5058
if (isCPP11 && tok->str () == " using" )
5062
5059
return false ;
@@ -7277,7 +7274,7 @@ static const Token* parsedecl(const Token* type,
7277
7274
valuetype->container = container;
7278
7275
} else {
7279
7276
const Scope *scope = type->scope ();
7280
- valuetype->typeScope = scope->symdb -> findScope (typeTokens.front (), scope);
7277
+ valuetype->typeScope = scope->symdb . findScope (typeTokens.front (), scope);
7281
7278
if (valuetype->typeScope )
7282
7279
valuetype->type = (scope->type == Scope::ScopeType::eClass) ? ValueType::Type::RECORD : ValueType::Type::NONSTD;
7283
7280
}
0 commit comments