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

Function getVariableTokenAfterAttributes

lib/tokenize.cpp:9486–9511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9484}
9485
9486static Token* getVariableTokenAfterAttributes(Token* tok) {
9487 Token *vartok = nullptr;
9488 Token *after = getTokenAfterAttributes(tok, true);
9489
9490 // check if after variable name
9491 if (Token::Match(after, "[;={]")) {
9492 Token *prev = tok->previous();
9493 while (Token::simpleMatch(prev, "]"))
9494 prev = prev->link()->previous();
9495 if (Token::Match(prev, "%type%"))
9496 vartok = prev;
9497 }
9498
9499
9500 // check if before variable name
9501 else {
9502 while (Token::Match(after->next(), "const|volatile|static|*|&|&&|%type%")) {
9503 after = after->next();
9504 }
9505 if (Token::Match(after, "%name%")) {
9506 vartok = after;
9507 }
9508 }
9509
9510 return vartok;
9511}
9512
9513Token* Tokenizer::getAttributeFuncTok(Token* tok, bool gccattr) const {
9514 if (!Token::Match(tok, "%name% ("))

Callers 2

simplifyAttributeMethod · 0.85
simplifyCPPAttributeMethod · 0.85

Calls 3

getTokenAfterAttributesFunction · 0.85
nextMethod · 0.80
simpleMatchFunction · 0.70

Tested by

no test coverage detected