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

Function evalCond

lib/forwardanalyzer.cpp:108–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106 }
107
108 std::pair<bool, bool> evalCond(const Token* tok, const Token* ctx = nullptr) const {
109 if (!tok)
110 return std::make_pair(false, false);
111 std::vector<MathLib::bigint> result = analyzer->evaluate(tok, ctx);
112 // TODO: We should convert to bool
113 const bool checkThen = std::any_of(result.cbegin(), result.cend(), [](MathLib::bigint x) {
114 return x != 0;
115 });
116 const bool checkElse = std::any_of(result.cbegin(), result.cend(), [](MathLib::bigint x) {
117 return x == 0;
118 });
119 return std::make_pair(checkThen, checkElse);
120 }
121
122 bool isConditionTrue(const Token* tok, const Token* ctx = nullptr) const {
123 return evalCond(tok, ctx).first;

Callers 5

isDeadCodeMethod · 0.85
isConditionTrueFunction · 0.85
traverseConditionalFunction · 0.85
updateLoopFunction · 0.85
updateRangeFunction · 0.85

Calls 1

evaluateMethod · 0.80

Tested by

no test coverage detected