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

Method testValueOfX_

test/testvalueflow.cpp:323–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321
322#define testValueOfX(...) testValueOfX_(__FILE__, __LINE__, __VA_ARGS__)
323 bool testValueOfX_(const char* file, int line, const char code[], unsigned int linenr, MathLib::bigint value, const Settings *s = nullptr) {
324 const Settings *settings1 = s ? s : &settings;
325
326 // Tokenize..
327 SimpleTokenizer tokenizer(*settings1, *this);
328 ASSERT_LOC(tokenizer.tokenize(code), file, line);
329
330 for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) {
331 if (tok->str() == "x" && tok->linenr() == linenr) {
332 if (std::any_of(tok->values().cbegin(), tok->values().cend(), [&](const ValueFlow::Value& v) {
333 return v.isIntValue() && !v.isImpossible() && v.intvalue == value;
334 }))
335 return true;
336 }
337 }
338
339 return false;
340 }
341
342 bool testValueOfX_(const char* file, int line, const char code[], unsigned int linenr, const std::string& expr, int value)
343 {

Callers

nothing calls this directly

Calls 6

tokenizeMethod · 0.80
nextMethod · 0.80
isImpossibleMethod · 0.80
simpleMatchFunction · 0.50
strMethod · 0.45
expressionStringMethod · 0.45

Tested by

no test coverage detected