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

Function derefShared

lib/valueflow.cpp:1497–1507  ·  view source on GitHub ↗

Check if dereferencing an object that doesn't have unique ownership

Source from the content-addressed store, hash-verified

1495
1496// Check if dereferencing an object that doesn't have unique ownership
1497static bool derefShared(const Token* tok)
1498{
1499 if (!tok)
1500 return false;
1501 if (!tok->isUnaryOp("*") && tok->str() != "[" && tok->str() != ".")
1502 return false;
1503 if (tok->str() == "." && tok->originalName() != "->")
1504 return false;
1505 const Token* ptrTok = tok->astOperand1();
1506 return !hasUniqueOwnership(ptrTok);
1507}
1508
1509ValueFlow::Value ValueFlow::getLifetimeObjValue(const Token *tok, bool inconclusive)
1510{

Callers 2

getLifetimeTokensFunction · 0.85

Calls 4

hasUniqueOwnershipFunction · 0.85
isUnaryOpMethod · 0.80
astOperand1Method · 0.80
strMethod · 0.45

Tested by

no test coverage detected