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

Function matchMemberName

lib/tokenize.cpp:5130–5174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5128}
5129
5130static Token * matchMemberName(const std::list<std::string> &scope, const Token *nsToken, Token *memberToken, const std::list<ScopeInfo2> &scopeInfo)
5131{
5132 auto scopeIt = scopeInfo.cbegin();
5133
5134 // Current scope..
5135 for (auto it = scope.cbegin(); it != scope.cend(); ++it) {
5136 if (scopeIt == scopeInfo.cend() || scopeIt->name != *it)
5137 return nullptr;
5138 ++scopeIt;
5139 }
5140
5141 // using namespace..
5142 if (nsToken) {
5143 while (Token::Match(nsToken, "%name% ::")) {
5144 if (scopeIt != scopeInfo.end() && nsToken->str() == scopeIt->name) {
5145 nsToken = nsToken->tokAt(2);
5146 ++scopeIt;
5147 } else {
5148 return nullptr;
5149 }
5150 }
5151 if (!Token::Match(nsToken, "%name% ;"))
5152 return nullptr;
5153 if (scopeIt == scopeInfo.end() || nsToken->str() != scopeIt->name)
5154 return nullptr;
5155 ++scopeIt;
5156 }
5157
5158 // Parse member tokens..
5159 while (scopeIt != scopeInfo.end()) {
5160 if (!Token::Match(memberToken, "%name% ::|<"))
5161 return nullptr;
5162 if (memberToken->str() != scopeIt->name)
5163 return nullptr;
5164 if (memberToken->strAt(1) == "<") {
5165 memberToken = memberToken->next()->findClosingBracket();
5166 if (!Token::simpleMatch(memberToken, "> ::"))
5167 return nullptr;
5168 }
5169 memberToken = memberToken->tokAt(2);
5170 ++scopeIt;
5171 }
5172
5173 return Token::Match(memberToken, "~| %name%") ? memberToken : nullptr;
5174}
5175
5176static Token * matchMemberName(const Member &member, const std::list<ScopeInfo2> &scopeInfo)
5177{

Callers 2

matchMemberVarNameFunction · 0.85
matchMemberFunctionNameFunction · 0.85

Calls 7

nextMethod · 0.80
simpleMatchFunction · 0.70
endMethod · 0.45
strMethod · 0.45
tokAtMethod · 0.45
findClosingBracketMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected