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

Function isConditionKnown

lib/valueflow.cpp:1386–1398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1384}
1385
1386static bool isConditionKnown(const Token* tok, bool then)
1387{
1388 const char* op = "||";
1389 if (then)
1390 op = "&&";
1391 const Token* parent = tok->astParent();
1392 while (parent && (parent->str() == op || parent->str() == "!" || parent->isCast()))
1393 parent = parent->astParent();
1394 const Token* top = tok->astTop();
1395 if (Token::Match(top->previous(), "if|while|for ("))
1396 return parent == top || Token::simpleMatch(parent, ";");
1397 return parent && parent->str() != op;
1398}
1399
1400enum class LifetimeCapture : std::uint8_t { Undefined, ByValue, ByReference };
1401

Callers 2

getContextAndValuesMethod · 0.85

Calls 5

astParentMethod · 0.80
isCastMethod · 0.80
astTopMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected