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

Method createSymbolDatabaseIncompleteVars

lib/symboldatabase.cpp:1493–1566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1491}
1492
1493void SymbolDatabase::createSymbolDatabaseIncompleteVars()
1494{
1495 for (Token* tok = mTokenizer.list.front(); tok != mTokenizer.list.back(); tok = tok->next()) {
1496 const Scope * scope = tok->scope();
1497 if (!scope)
1498 continue;
1499 if (!scope->isExecutable())
1500 continue;
1501 if (tok->varId() != 0)
1502 continue;
1503 if (tok->isCast() && !isCPPCast(tok) && tok->link() && tok->str() == "(") {
1504 tok = tok->link();
1505 continue;
1506 }
1507 if (tok->isCpp()) {
1508 if (Token::Match(tok, "catch|typeid (") ||
1509 Token::Match(tok, "static_cast|dynamic_cast|const_cast|reinterpret_cast")) {
1510 tok = tok->linkAt(1);
1511 continue;
1512 }
1513 if (tok->str() == "using") {
1514 Token* usingEnd = Token::findsimplematch(tok, ";");
1515 if (!usingEnd)
1516 mTokenizer.syntaxError(tok);
1517 tok = usingEnd;
1518 continue;
1519 }
1520 }
1521 if (tok->str() == "NULL")
1522 continue;
1523 if (tok->isKeyword() || !tok->isNameOnly())
1524 continue;
1525 if (tok->type())
1526 continue;
1527 if (Token::Match(tok->next(), "::|.|(|{|:|%var%"))
1528 continue;
1529 if (Token::Match(tok->next(), "&|&&|* *| *| )|,|%var%|const"))
1530 continue;
1531 if (Token::Match(tok->previous(), "%str%"))
1532 continue;
1533 // Very likely a typelist
1534 if (Token::Match(tok->tokAt(-2), "%type% ,") || Token::Match(tok->next(), ", %type%"))
1535 continue;
1536 // Inside template brackets
1537 if (Token::simpleMatch(tok->next(), "<") && tok->linkAt(1)) {
1538 tok = tok->linkAt(1);
1539 continue;
1540 }
1541 // Skip goto labels
1542 if (Token::simpleMatch(tok->previous(), "goto"))
1543 continue;
1544 std::string fstr = tok->str();
1545 const Token* ftok = tok->previous();
1546 while (Token::simpleMatch(ftok, "::")) {
1547 if (!Token::Match(ftok->previous(), "%name%"))
1548 break;
1549 fstr.insert(0, ftok->strAt(-1) + "::");
1550 ftok = ftok->tokAt(-2);

Callers

nothing calls this directly

Calls 15

isCPPCastFunction · 0.85
findsimplematchFunction · 0.85
frontMethod · 0.80
nextMethod · 0.80
scopeMethod · 0.80
isCastMethod · 0.80
linkAtMethod · 0.80
typeMethod · 0.80
astParentMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45
syntaxErrorMethod · 0.45

Tested by

no test coverage detected