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

Method createSymbolDatabaseEnums

lib/symboldatabase.cpp:1445–1491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1443}
1444
1445void SymbolDatabase::createSymbolDatabaseEnums()
1446{
1447 // fill in enumerators in enum
1448 for (const Scope &scope : scopeList) {
1449 if (scope.type != ScopeType::eEnum)
1450 continue;
1451
1452 // add enumerators to enumerator tokens
1453 for (const Enumerator & i : scope.enumeratorList)
1454 const_cast<Token *>(i.name)->enumerator(&i);
1455 }
1456
1457 std::set<std::string> tokensThatAreNotEnumeratorValues;
1458
1459 for (const Scope &scope : scopeList) {
1460 if (scope.type != ScopeType::eEnum)
1461 continue;
1462
1463 for (const Enumerator & enumerator : scope.enumeratorList) {
1464 // look for initialization tokens that can be converted to enumerators and convert them
1465 if (enumerator.start) {
1466 if (!enumerator.end)
1467 mTokenizer.syntaxError(enumerator.start);
1468 for (const Token * tok3 = enumerator.start; tok3 && tok3 != enumerator.end->next(); tok3 = tok3->next()) {
1469 if (tok3->tokType() == Token::eName) {
1470 const Enumerator * e = findEnumerator(tok3, tokensThatAreNotEnumeratorValues);
1471 if (e)
1472 const_cast<Token *>(tok3)->enumerator(e);
1473 }
1474 }
1475 }
1476 }
1477 }
1478
1479 // find enumerators
1480 for (Token* tok = mTokenizer.list.front(); tok != mTokenizer.list.back(); tok = tok->next()) {
1481 const bool isVariable = (tok->tokType() == Token::eVariable && !tok->variable());
1482 if (tok->tokType() != Token::eName && !isVariable)
1483 continue;
1484 const Enumerator * enumerator = findEnumerator(tok, tokensThatAreNotEnumeratorValues);
1485 if (enumerator) {
1486 if (isVariable)
1487 tok->varId(0);
1488 tok->enumerator(enumerator);
1489 }
1490 }
1491}
1492
1493void SymbolDatabase::createSymbolDatabaseIncompleteVars()
1494{

Callers

nothing calls this directly

Calls 5

findEnumeratorFunction · 0.85
nextMethod · 0.80
frontMethod · 0.80
variableMethod · 0.80
syntaxErrorMethod · 0.45

Tested by

no test coverage detected