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

Method setVarIdClassFunction

lib/tokenize.cpp:4656–4683  ·  view source on GitHub ↗

Update the variable ids.. Parse each function..

Source from the content-addressed store, hash-verified

4654// Update the variable ids..
4655// Parse each function..
4656void Tokenizer::setVarIdClassFunction(const std::string &classname,
4657 Token * const startToken,
4658 const Token * const endToken,
4659 const std::map<std::string, nonneg int> &varlist,
4660 std::map<nonneg int, std::map<std::string, nonneg int>>& structMembers,
4661 nonneg int &varId_)
4662{
4663 const auto pos = classname.rfind(' '); // TODO handle multiple scopes
4664 const std::string lastScope = classname.substr(pos == std::string::npos ? 0 : pos + 1);
4665 for (Token *tok2 = startToken; tok2 && tok2 != endToken; tok2 = tok2->next()) {
4666 if (tok2->varId() != 0 || !tok2->isName())
4667 continue;
4668 if (Token::Match(tok2->tokAt(-2), ("!!" + lastScope + " ::").c_str()))
4669 continue;
4670 if (Token::Match(tok2->tokAt(-4), "%name% :: %name% ::")) // Currently unsupported
4671 continue;
4672 if (Token::Match(tok2->tokAt(-2), "!!this .") && !Token::simpleMatch(tok2->tokAt(-5), "( * this ) ."))
4673 continue;
4674 if (Token::Match(tok2, "%name% ::"))
4675 continue;
4676
4677 const auto it = varlist.find(tok2->str());
4678 if (it != varlist.end()) {
4679 tok2->varId(it->second);
4680 setVarIdStructMembers(tok2, structMembers, varId_);
4681 }
4682 }
4683}
4684
4685
4686

Callers

nothing calls this directly

Calls 7

setVarIdStructMembersFunction · 0.85
nextMethod · 0.80
simpleMatchFunction · 0.70
tokAtMethod · 0.45
findMethod · 0.45
strMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected