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

Method testValueOfXKnown_

test/testvalueflow.cpp:214–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212
213#define testValueOfXKnown(...) testValueOfXKnown_(__FILE__, __LINE__, __VA_ARGS__)
214 bool testValueOfXKnown_(const char* file, int line, const char code[], unsigned int linenr, int value) {
215 // Tokenize..
216 SimpleTokenizer tokenizer(settings, *this);
217 ASSERT_LOC(tokenizer.tokenize(code), file, line);
218
219 for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) {
220 if (tok->str() == "x" && tok->linenr() == linenr) {
221 if (std::any_of(tok->values().begin(), tok->values().end(), [&](const ValueFlow::Value& val) {
222 if (val.isSymbolicValue())
223 return false;
224 if (val.isKnown() && val.intvalue == value)
225 return true;
226 return false;
227 }))
228 return true;
229 }
230 }
231
232 return false;
233 }
234
235 bool testValueOfXKnown_(const char* file, int line, const char code[], unsigned int linenr, const std::string& expr, int value) {
236 // Tokenize..

Callers

nothing calls this directly

Calls 7

tokenizeMethod · 0.80
nextMethod · 0.80
isKnownMethod · 0.80
strMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
expressionStringMethod · 0.45

Tested by

no test coverage detected