| 2172 | } |
| 2173 | |
| 2174 | static void removeOverlaps(std::list<ValueFlow::Value>& values) |
| 2175 | { |
| 2176 | for (const ValueFlow::Value& x : values) { |
| 2177 | if (x.isNonValue()) |
| 2178 | continue; |
| 2179 | values.remove_if([&](const ValueFlow::Value& y) { |
| 2180 | if (y.isNonValue()) |
| 2181 | return false; |
| 2182 | if (&x == &y) |
| 2183 | return false; |
| 2184 | if (x.valueType != y.valueType) |
| 2185 | return false; |
| 2186 | if (x.valueKind != y.valueKind) |
| 2187 | return false; |
| 2188 | // TODO: Remove points covered in a lower or upper bound |
| 2189 | // TODO: Remove lower or upper bound already covered by a lower and upper bound |
| 2190 | if (!x.equalValue(y)) |
| 2191 | return false; |
| 2192 | if (x.bound != y.bound) |
| 2193 | return false; |
| 2194 | return true; |
| 2195 | }); |
| 2196 | } |
| 2197 | mergeAdjacent(values); |
| 2198 | } |
| 2199 | |
| 2200 | // Removing contradictions is an NP-hard problem. Instead we run multiple |
| 2201 | // passes to try to catch most contradictions |
no test coverage detected