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

Method parse

lib/valueflow.cpp:4983–5009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4981
4982struct SimpleConditionHandler : ConditionHandler {
4983 std::vector<Condition> parse(const Token* tok, const Settings& /*settings*/) const override {
4984
4985 std::vector<Condition> conds;
4986 parseCompareEachInt(tok, [&](const Token* vartok, ValueFlow::Value true_value, ValueFlow::Value false_value) {
4987 if (vartok->hasKnownIntValue())
4988 return;
4989 if (vartok->str() == "=" && vartok->astOperand1() && vartok->astOperand2())
4990 vartok = vartok->astOperand1();
4991 Condition cond;
4992 cond.true_values.push_back(std::move(true_value));
4993 cond.false_values.push_back(std::move(false_value));
4994 cond.vartok = vartok;
4995 conds.push_back(std::move(cond));
4996 });
4997 if (!conds.empty())
4998 return conds;
4999
5000 const Token* vartok = getConditionVariable(tok);
5001 if (!vartok)
5002 return {};
5003 Condition cond;
5004 cond.true_values.emplace_back(tok, 0LL);
5005 cond.false_values.emplace_back(tok, 0LL);
5006 cond.vartok = vartok;
5007
5008 return {std::move(cond)};
5009 }
5010};
5011
5012struct IteratorInferModel : InferModel {

Callers

nothing calls this directly

Calls 8

parseCompareEachIntFunction · 0.85
getConditionVariableFunction · 0.85
astOperand1Method · 0.80
astOperand2Method · 0.80
hasKnownIntValueMethod · 0.45
strMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected