| 6413 | |
| 6414 | struct IteratorConditionHandler : SimpleConditionHandler { |
| 6415 | std::vector<Condition> parse(const Token* tok, const Settings& /*settings*/) const override { |
| 6416 | Condition cond; |
| 6417 | |
| 6418 | if (Token::Match(tok, "==|!=")) { |
| 6419 | if (!tok->astOperand1() || !tok->astOperand2()) |
| 6420 | return {}; |
| 6421 | |
| 6422 | constexpr ValueFlow::Value::ValueKind kind = ValueFlow::Value::ValueKind::Known; |
| 6423 | std::list<ValueFlow::Value> values = getIteratorValues(tok->astOperand1()->values(), &kind); |
| 6424 | if (!values.empty()) { |
| 6425 | cond.vartok = tok->astOperand2(); |
| 6426 | } else { |
| 6427 | values = getIteratorValues(tok->astOperand2()->values(), &kind); |
| 6428 | if (!values.empty()) |
| 6429 | cond.vartok = tok->astOperand1(); |
| 6430 | } |
| 6431 | for (ValueFlow::Value& v:values) { |
| 6432 | v.setPossible(); |
| 6433 | v.assumeCondition(tok); |
| 6434 | } |
| 6435 | cond.true_values = values; |
| 6436 | cond.false_values = std::move(values); |
| 6437 | } |
| 6438 | |
| 6439 | return {std::move(cond)}; |
| 6440 | } |
| 6441 | }; |
| 6442 | |
| 6443 | static void valueFlowIteratorInfer(TokenList& tokenlist, const Settings& settings) |
nothing calls this directly
no test coverage detected