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

Function isIteratorPair

lib/astutils.cpp:3253–3274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3251}
3252
3253bool isIteratorPair(const std::vector<const Token*>& args)
3254{
3255 if (args.size() != 2)
3256 return false;
3257 if (astIsPointer(args[0]) && astIsPointer(args[1]))
3258 return true;
3259 // Check if iterator is from same container
3260 const Token* tok1 = nullptr;
3261 const Token* tok2 = nullptr;
3262 if (astIsIterator(args[0]) && astIsIterator(args[1])) {
3263 tok1 = ValueFlow::getLifetimeObjValue(args[0]).tokvalue;
3264 tok2 = ValueFlow::getLifetimeObjValue(args[1]).tokvalue;
3265 if (!tok1 || !tok2)
3266 return true;
3267 } else {
3268 tok1 = getIteratorExpression(args[0]);
3269 tok2 = getIteratorExpression(args[1]);
3270 }
3271 if (tok1 && tok2)
3272 return tok1->exprId() == tok2->exprId();
3273 return tok1 || tok2;
3274}
3275
3276const Token *findLambdaStartToken(const Token *last)
3277{

Callers 3

getInitListSizeFunction · 0.85
valueFlowContainerSizeFunction · 0.85

Calls 4

astIsPointerFunction · 0.85
astIsIteratorFunction · 0.85
getIteratorExpressionFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected