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

Method compare

lib/infer.cpp:200–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198 }
199
200 static std::vector<int> compare(const Interval& lhs,
201 const Interval& rhs,
202 std::vector<const ValueFlow::Value*>* ref = nullptr)
203 {
204 Interval diff = lhs - rhs;
205 if (diff.isGreaterThan(0, ref))
206 return {1};
207 if (diff.isLessThan(0, ref))
208 return {-1};
209 std::vector<int> eq = Interval::equal(lhs, rhs, ref);
210 if (!eq.empty()) {
211 if (eq.front() == 0)
212 return {1, -1};
213 return {0};
214 }
215 if (diff.isGreaterThan(-1, ref))
216 return {0, 1};
217 if (diff.isLessThan(1, ref))
218 return {0, -1};
219 return {};
220 }
221
222 static std::vector<bool> compare(const std::string& op,
223 const Interval& lhs,

Callers

nothing calls this directly

Calls 5

calculateFunction · 0.85
isGreaterThanMethod · 0.80
isLessThanMethod · 0.80
frontMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected