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

Function skipPointers

lib/symboldatabase.cpp:5286–5322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5284}
5285
5286static const Token* skipPointers(const Token* tok)
5287{
5288 const Token *start = tok;
5289 bool memberPointer = false;
5290 while (tok) {
5291 if (Token::simpleMatch(tok, "::")) {
5292 tok = tok->next();
5293 continue;
5294 }
5295 if (Token::Match(tok, "%type% ::")) {
5296 tok = tok->tokAt(2);
5297 memberPointer = true;
5298 continue;
5299 }
5300 if (Token::Match(tok, "%type% <") && tok->linkAt(1)) {
5301 tok = tok->linkAt(1)->next();
5302 continue;
5303 }
5304 break;
5305 }
5306 if (memberPointer && !Token::simpleMatch(tok, "*"))
5307 return start;
5308 while (Token::Match(tok, "*|&|&&") || (Token::Match(tok, "( [*&]") && Token::Match(tok->link()->next(), "(|["))) {
5309 tok = tok->next();
5310 if (tok && tok->strAt(-1) == "(" && Token::Match(tok, "%type% ::"))
5311 tok = tok->tokAt(2);
5312 }
5313
5314 if (Token::simpleMatch(tok, "( *") && Token::simpleMatch(tok->link()->previous(), "] ) ;") &&
5315 (tok->tokAt(-1)->isStandardType() || tok->tokAt(-1)->isKeyword() || tok->strAt(-1) == "*")) {
5316 const Token *tok2 = skipPointers(tok->next());
5317 if (Token::Match(tok2, "%name% [") && Token::simpleMatch(tok2->linkAt(1), "] ) ;"))
5318 return tok2;
5319 }
5320
5321 return tok;
5322}
5323
5324static const Token* skipPointersAndQualifiers(const Token* tok)
5325{

Callers 2

isVariableDeclarationMethod · 0.85

Calls 6

nextMethod · 0.80
linkAtMethod · 0.80
simpleMatchFunction · 0.70
tokAtMethod · 0.45
isStandardTypeMethod · 0.45
isKeywordMethod · 0.45

Tested by

no test coverage detected