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

Method parseCompareInt

lib/valueflow.cpp:332–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330}
331
332const Token* ValueFlow::parseCompareInt(const Token* tok,
333 ValueFlow::Value& true_value,
334 ValueFlow::Value& false_value,
335 const std::function<std::vector<MathLib::bigint>(const Token*)>& evaluate)
336{
337 const Token* result = nullptr;
338 parseCompareEachInt(
339 tok,
340 [&](const Token* vartok, ValueFlow::Value true_value2, ValueFlow::Value false_value2) {
341 if (result)
342 return;
343 result = vartok;
344 true_value = std::move(true_value2);
345 false_value = std::move(false_value2);
346 },
347 [&](const Token* t) -> std::vector<ValueFlow::Value> {
348 std::vector<ValueFlow::Value> r;
349 std::vector<MathLib::bigint> v = evaluate(t);
350
351 std::transform(v.cbegin(), v.cend(), std::back_inserter(r), [&](MathLib::bigint i) {
352 return ValueFlow::Value{i};
353 });
354 return r;
355 });
356 return result;
357}
358
359const Token *ValueFlow::parseCompareInt(const Token *tok, ValueFlow::Value &true_value, ValueFlow::Value &false_value)
360{

Callers

nothing calls this directly

Calls 3

parseCompareEachIntFunction · 0.85
getKnownValueMethod · 0.80
evaluateFunction · 0.70

Tested by

no test coverage detected