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

Method createSymbolDatabaseSetScopePointers

lib/symboldatabase.cpp:1133–1172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1131}
1132
1133void SymbolDatabase::createSymbolDatabaseSetScopePointers()
1134{
1135 auto setScopePointers = [](const Scope &scope, const Token *bodyStart, const Token *bodyEnd) {
1136 assert(bodyStart);
1137 assert(bodyEnd);
1138
1139 const_cast<Token *>(bodyEnd)->scope(&scope);
1140
1141 for (auto* tok = const_cast<Token *>(bodyStart); tok != bodyEnd; tok = tok->next()) {
1142 if (bodyStart != bodyEnd && tok->str() == "{") {
1143 bool isEndOfScope = false;
1144 for (Scope* innerScope: scope.nestedList) {
1145 const auto &list = innerScope->bodyStartList;
1146 if (std::find(list.cbegin(), list.cend(), tok) != list.cend()) { // Is begin of inner scope
1147 tok = tok->link();
1148 if (tok->next() == bodyEnd || !tok->next()) {
1149 isEndOfScope = true;
1150 break;
1151 }
1152 tok = tok->next();
1153 break;
1154 }
1155 }
1156 if (isEndOfScope)
1157 break;
1158 }
1159 tok->scope(&scope);
1160 }
1161 };
1162
1163 // Set scope pointers
1164 for (const Scope& scope: scopeList) {
1165 if (scope.type == ScopeType::eGlobal)
1166 setScopePointers(scope, mTokenizer.list.front(), mTokenizer.list.back());
1167 else {
1168 for (const Token *bodyStart: scope.bodyStartList)
1169 setScopePointers(scope, bodyStart, bodyStart->link());
1170 }
1171 }
1172}
1173
1174void SymbolDatabase::createSymbolDatabaseSetFunctionPointers(bool firstPass)
1175{

Callers

nothing calls this directly

Calls 4

scopeMethod · 0.80
nextMethod · 0.80
frontMethod · 0.80
strMethod · 0.45

Tested by

no test coverage detected