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

Method testLifetimeOfX_

test/testvalueflow.cpp:421–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

419#define testLifetimeOfX(...) testLifetimeOfX_(__FILE__, __LINE__, __VA_ARGS__)
420 template<size_t size>
421 bool testLifetimeOfX_(const char* file, int line, const char (&code)[size], unsigned int linenr, const char value[]) {
422 // Tokenize..
423 SimpleTokenizer tokenizer(settings, *this);
424 ASSERT_LOC(tokenizer.tokenize(code), file, line);
425
426 const std::size_t len = strlen(value);
427 for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) {
428 if (tok->str() == "x" && tok->linenr() == linenr) {
429 if (std::any_of(tok->values().cbegin(), tok->values().cend(), [&](const ValueFlow::Value& v) {
430 return v.isLifetimeValue() && v.lifetimeScope == ValueFlow::Value::LifetimeScope::Local && Token::simpleMatch(v.tokvalue, value, len);
431 }))
432 return true;
433 }
434 }
435
436 return false;
437 }
438
439 bool testValueOfX_(const char* file, int line, const char code[], unsigned int linenr, int value, ValueFlow::Value::ValueType type) {
440 // Tokenize..

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected