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

Method getAttributeFuncTok

lib/tokenize.cpp:9513–9550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9511}
9512
9513Token* Tokenizer::getAttributeFuncTok(Token* tok, bool gccattr) const {
9514 if (!Token::Match(tok, "%name% ("))
9515 return nullptr;
9516 Token* const after = getTokenAfterAttributes(tok, gccattr);
9517 if (!after)
9518 syntaxError(tok);
9519
9520 if (Token::Match(after, "%name%|*|&|(")) {
9521 Token *ftok = after;
9522 while (Token::Match(ftok, "%name%|::|<|*|& !!(")) {
9523 if (ftok->str() == "<") {
9524 ftok = ftok->findClosingBracket();
9525 if (!ftok)
9526 break;
9527 }
9528 ftok = ftok->next();
9529 }
9530 if (Token::simpleMatch(ftok, "( *"))
9531 ftok = ftok->tokAt(2);
9532 if (Token::Match(ftok, "%name% (|)"))
9533 return ftok;
9534 } else if (Token::Match(after, "[;{=:]")) {
9535 Token *prev = tok->previous();
9536 while (Token::Match(prev, "%name%"))
9537 prev = prev->previous();
9538 if (Token::simpleMatch(prev, ")")) {
9539 if (Token::Match(prev->link()->previous(), "%name% ("))
9540 return prev->link()->previous();
9541 if (isFunctionPointer(prev->link()->tokAt(-2)))
9542 return prev->link()->tokAt(-2);
9543 }
9544 if (Token::simpleMatch(prev, ")") && Token::Match(prev->link()->tokAt(-2), "operator %op% (") && isCPP())
9545 return prev->link()->tokAt(-2);
9546 if ((!prev || Token::Match(prev, "[;{}*]")) && Token::Match(tok->previous(), "%name%"))
9547 return tok->previous();
9548 }
9549 return nullptr;
9550}
9551
9552void Tokenizer::simplifyDeclspec()
9553{

Callers

nothing calls this directly

Calls 8

getTokenAfterAttributesFunction · 0.85
isFunctionPointerFunction · 0.85
isCPPFunction · 0.85
nextMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45
findClosingBracketMethod · 0.45
tokAtMethod · 0.45

Tested by

no test coverage detected