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

Function getIteratorExpression

lib/astutils.cpp:3228–3251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3226}
3227
3228const Token* getIteratorExpression(const Token* tok)
3229{
3230 if (!tok)
3231 return nullptr;
3232 if (tok->isUnaryOp("*"))
3233 return nullptr;
3234 if (!tok->isName()) {
3235 const Token* iter1 = getIteratorExpression(tok->astOperand1());
3236 if (iter1)
3237 return iter1;
3238 if (tok->str() == "(")
3239 return nullptr;
3240 const Token* iter2 = getIteratorExpression(tok->astOperand2());
3241 if (iter2)
3242 return iter2;
3243 } else if (Token::Match(tok, "begin|cbegin|rbegin|crbegin|end|cend|rend|crend (")) {
3244 if (Token::Match(tok->previous(), ". %name% ( ) !!."))
3245 return tok->previous()->astOperand1();
3246 if (!Token::simpleMatch(tok->previous(), ".") && Token::Match(tok, "%name% ( !!)") &&
3247 !Token::simpleMatch(tok->linkAt(1), ") ."))
3248 return tok->next()->astOperand2();
3249 }
3250 return nullptr;
3251}
3252
3253bool isIteratorPair(const std::vector<const Token*>& args)
3254{

Callers 2

checkIteratorPairMethod · 0.85
isIteratorPairFunction · 0.85

Calls 7

isUnaryOpMethod · 0.80
astOperand1Method · 0.80
astOperand2Method · 0.80
linkAtMethod · 0.80
nextMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected