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

Function isBracketAccess

lib/checkother.cpp:2208–2220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2206}
2207
2208static bool isBracketAccess(const Token* tok)
2209{
2210 if (!Token::simpleMatch(tok, "[") || !tok->astOperand1())
2211 return false;
2212 tok = tok->astOperand1();
2213 if (tok->str() == ".")
2214 tok = tok->astOperand2();
2215 while (Token::simpleMatch(tok, "["))
2216 tok = tok->astOperand1();
2217 if (!tok || !tok->variable())
2218 return false;
2219 return tok->variable()->nameToken() != tok;
2220}
2221
2222static bool isConstant(const Token* tok) {
2223 return tok && (tok->isEnumerator() || Token::Match(tok, "%bool%|%num%|%str%|%char%|nullptr|NULL"));

Callers 1

isConstStatementFunction · 0.85

Calls 6

astOperand1Method · 0.80
astOperand2Method · 0.80
variableMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45
nameTokenMethod · 0.45

Tested by

no test coverage detected