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

Method testConditionalValueOfX_

test/testvalueflow.cpp:475–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473#define testConditionalValueOfX(...) testConditionalValueOfX_(__FILE__, __LINE__, __VA_ARGS__)
474 template<size_t size>
475 bool testConditionalValueOfX_(const char* file, int line, const char (&code)[size], unsigned int linenr, int value) {
476 // Tokenize..
477 SimpleTokenizer tokenizer(settings, *this);
478 ASSERT_LOC(tokenizer.tokenize(code), file, line);
479
480 for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) {
481 if (tok->str() == "x" && tok->linenr() == linenr) {
482 if (std::any_of(tok->values().cbegin(), tok->values().cend(), [&](const ValueFlow::Value& v) {
483 return v.isIntValue() && v.intvalue == value && v.condition;
484 }))
485 return true;
486 }
487 }
488
489 return false;
490 }
491
492#define bailout(...) bailout_(__FILE__, __LINE__, __VA_ARGS__)
493 template<size_t size>

Callers

nothing calls this directly

Calls 3

tokenizeMethod · 0.80
nextMethod · 0.80
strMethod · 0.45

Tested by

no test coverage detected