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

Function valueFlowIterators

lib/valueflow.cpp:6376–6401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6374}
6375
6376static void valueFlowIterators(TokenList& tokenlist, const Settings& settings)
6377{
6378 for (Token* tok = tokenlist.front(); tok; tok = tok->next()) {
6379 if (!tok->scope())
6380 continue;
6381 if (!tok->scope()->isExecutable())
6382 continue;
6383 if (!astIsContainer(tok))
6384 continue;
6385 const Token* ftok = nullptr;
6386 const Library::Container::Yield yield = findIteratorYield(tok, ftok, settings.library);
6387 if (!ftok)
6388 continue;
6389 if (yield == Library::Container::Yield::START_ITERATOR) {
6390 ValueFlow::Value v(0);
6391 v.setKnown();
6392 v.valueType = ValueFlow::Value::ValueType::ITERATOR_START;
6393 setTokenValue(const_cast<Token*>(ftok)->next(), std::move(v), settings);
6394 } else if (yield == Library::Container::Yield::END_ITERATOR) {
6395 ValueFlow::Value v(0);
6396 v.setKnown();
6397 v.valueType = ValueFlow::Value::ValueType::ITERATOR_END;
6398 setTokenValue(const_cast<Token*>(ftok)->next(), std::move(v), settings);
6399 }
6400 }
6401}
6402
6403static std::list<ValueFlow::Value> getIteratorValues(std::list<ValueFlow::Value> values,
6404 const ValueFlow::Value::ValueKind* kind = nullptr)

Callers 1

setValuesMethod · 0.85

Calls 6

astIsContainerFunction · 0.85
findIteratorYieldFunction · 0.85
setTokenValueFunction · 0.85
frontMethod · 0.80
nextMethod · 0.80
scopeMethod · 0.80

Tested by

no test coverage detected