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

Method checkCond

lib/pathanalysis.cpp:49–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49std::pair<bool, bool> PathAnalysis::checkCond(const Token * tok, bool& known)
50{
51 if (const ValueFlow::Value* v = tok->getKnownValue(ValueFlow::Value::ValueType::INT)) {
52 known = true;
53 return std::make_pair(!!v->intvalue, !v->intvalue);
54 }
55 auto it = std::find_if(tok->values().cbegin(), tok->values().cend(), [](const ValueFlow::Value& v) {
56 return v.isIntValue();
57 });
58 // If all possible values are the same, then assume all paths have the same value
59 if (it != tok->values().cend() && std::all_of(it, tok->values().cend(), [&](const ValueFlow::Value& v) {
60 if (v.isIntValue())
61 return v.intvalue == it->intvalue;
62 return true;
63 })) {
64 known = false;
65 return std::make_pair(!!it->intvalue, !it->intvalue);
66 }
67 return std::make_pair(true, true);
68}
69
70PathAnalysis::Progress PathAnalysis::forwardRecursive(const Token* tok, Info info, const std::function<PathAnalysis::Progress(const Info&)>& f)
71{

Callers

nothing calls this directly

Calls 1

getKnownValueMethod · 0.80

Tested by

no test coverage detected