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

Method testValueOfXImpossible_

test/testvalueflow.cpp:257–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255
256#define testValueOfXImpossible(...) testValueOfXImpossible_(__FILE__, __LINE__, __VA_ARGS__)
257 bool testValueOfXImpossible_(const char* file, int line, const char code[], unsigned int linenr, int value) {
258 // Tokenize..
259 SimpleTokenizer tokenizer(settings, *this);
260 ASSERT_LOC(tokenizer.tokenize(code), file, line);
261
262 for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) {
263 if (tok->str() == "x" && tok->linenr() == linenr) {
264 if (std::any_of(tok->values().begin(), tok->values().end(), [&](const ValueFlow::Value& val) {
265 if (val.isSymbolicValue())
266 return false;
267 if (val.isImpossible() && val.intvalue == value)
268 return true;
269 return false;
270 }))
271 return true;
272 }
273 }
274
275 return false;
276 }
277
278 bool testValueOfXImpossible_(const char* file, int line, const char code[], unsigned int linenr, const std::string& expr, int value)
279 {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected