MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / findScope

Method findScope

lib/symboldatabase.cpp:6580–6605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6578//---------------------------------------------------------------------------
6579
6580const Scope *SymbolDatabase::findScope(const Token *tok, const Scope *startScope) const
6581{
6582 const Scope *scope = nullptr;
6583 // absolute path
6584 if (tok->str() == "::") {
6585 tok = tok->next();
6586 scope = &scopeList.front();
6587 }
6588 // relative path
6589 else if (tok->isName()) {
6590 scope = startScope;
6591 }
6592
6593 while (scope && tok && tok->isName()) {
6594 if (tok->strAt(1) == "::") {
6595 scope = scope->findRecordInNestedList(tok->str());
6596 tok = tok->tokAt(2);
6597 } else if (tok->strAt(1) == "<")
6598 return nullptr;
6599 else
6600 return scope->findRecordInNestedList(tok->str());
6601 }
6602
6603 // not a valid path
6604 return nullptr;
6605}
6606
6607//---------------------------------------------------------------------------
6608

Callers 2

parsedeclFunction · 0.45
findScopeFunction · 0.45

Calls 5

nextMethod · 0.80
frontMethod · 0.80
strMethod · 0.45
tokAtMethod · 0.45

Tested by

no test coverage detected