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

Function isConstTop

lib/checkother.cpp:2327–2349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2325}
2326
2327static bool isConstTop(const Token *tok)
2328{
2329 if (!tok)
2330 return false;
2331 if (!tok->astParent())
2332 return true;
2333 if (Token::simpleMatch(tok->astParent(), ";") &&
2334 Token::Match(tok->astTop()->previous(), "for|if (") && Token::simpleMatch(tok->astTop()->astOperand2(), ";")) {
2335 if (Token::simpleMatch(tok->astParent()->astParent(), ";"))
2336 return tok->astParent()->astOperand2() == tok;
2337 return tok->astParent()->astOperand1() == tok;
2338 }
2339 if (Token::simpleMatch(tok, "[")) {
2340 const Token* bracTok = tok;
2341 while (Token::simpleMatch(bracTok->astParent(), "["))
2342 bracTok = bracTok->astParent();
2343 if (!bracTok->astParent())
2344 return true;
2345 }
2346 if (tok->str() == "," && tok->astParent()->isAssignmentOp())
2347 return true;
2348 return false;
2349}
2350
2351void CheckOtherImpl::checkIncompleteStatement()
2352{

Callers 1

Calls 7

astParentMethod · 0.80
astTopMethod · 0.80
astOperand2Method · 0.80
astOperand1Method · 0.80
isAssignmentOpMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected