| 6441 | }; |
| 6442 | |
| 6443 | static void valueFlowIteratorInfer(TokenList& tokenlist, const Settings& settings) |
| 6444 | { |
| 6445 | for (Token* tok = tokenlist.front(); tok; tok = tok->next()) { |
| 6446 | if (!tok->scope()) |
| 6447 | continue; |
| 6448 | if (!tok->scope()->isExecutable()) |
| 6449 | continue; |
| 6450 | std::list<ValueFlow::Value> values = getIteratorValues(tok->values()); |
| 6451 | values.remove_if([&](const ValueFlow::Value& v) { |
| 6452 | if (!v.isImpossible()) |
| 6453 | return true; |
| 6454 | if (!v.condition) |
| 6455 | return true; |
| 6456 | if (v.bound != ValueFlow::Value::Bound::Point) |
| 6457 | return true; |
| 6458 | if (v.isIteratorEndValue() && v.intvalue <= 0) |
| 6459 | return true; |
| 6460 | if (v.isIteratorStartValue() && v.intvalue >= 0) |
| 6461 | return true; |
| 6462 | return false; |
| 6463 | }); |
| 6464 | for (ValueFlow::Value& v : values) { |
| 6465 | v.setPossible(); |
| 6466 | if (v.isIteratorStartValue()) |
| 6467 | v.intvalue++; |
| 6468 | if (v.isIteratorEndValue()) |
| 6469 | v.intvalue--; |
| 6470 | setTokenValue(tok, std::move(v), settings); |
| 6471 | } |
| 6472 | } |
| 6473 | } |
| 6474 | |
| 6475 | static std::vector<ValueFlow::Value> getContainerValues(const Token* tok) |
| 6476 | { |
no test coverage detected