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

Function lifetimeType

lib/valueflow.cpp:1402–1422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1400enum class LifetimeCapture : std::uint8_t { Undefined, ByValue, ByReference };
1401
1402static std::string lifetimeType(const Token *tok, const ValueFlow::Value *val)
1403{
1404 if (!val)
1405 return "object";
1406 switch (val->lifetimeKind) {
1407 case ValueFlow::Value::LifetimeKind::Lambda:
1408 return "lambda";
1409 case ValueFlow::Value::LifetimeKind::Iterator:
1410 return "iterator";
1411 case ValueFlow::Value::LifetimeKind::Object:
1412 case ValueFlow::Value::LifetimeKind::SubObject:
1413 case ValueFlow::Value::LifetimeKind::Address:
1414 if (astIsPointer(tok))
1415 return "pointer";
1416 if (Token::simpleMatch(tok, "=") && astIsPointer(tok->astOperand2()))
1417 return "pointer";
1418 return "object";
1419 }
1420
1421 cppcheck::unreachable();
1422}
1423
1424std::string ValueFlow::lifetimeMessage(const Token *tok, const ValueFlow::Value *val, ErrorPath &errorPath)
1425{

Callers 2

lifetimeMessageMethod · 0.85

Calls 4

astIsPointerFunction · 0.85
unreachableFunction · 0.85
astOperand2Method · 0.80
simpleMatchFunction · 0.70

Tested by

no test coverage detected