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

Method isLifetimeBorrowed

lib/valueflow.cpp:1849–1871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1847}
1848
1849bool ValueFlow::isLifetimeBorrowed(const Token *tok, const Settings &settings)
1850{
1851 if (!tok)
1852 return true;
1853 if (tok->str() == ",")
1854 return true;
1855 if (!tok->astParent())
1856 return true;
1857 const Token* parent = nullptr;
1858 const ValueType* vt = tok->valueType();
1859 std::vector<ValueType> vtParents = getParentValueTypes(tok, settings, &parent);
1860 for (const ValueType& vtParent : vtParents) {
1861 if (isLifetimeBorrowed(vt, &vtParent))
1862 return true;
1863 if (isLifetimeOwned(vt, &vtParent))
1864 return false;
1865 }
1866 if (parent) {
1867 if (isDifferentType(tok, parent, settings))
1868 return false;
1869 }
1870 return true;
1871}
1872
1873static void valueFlowLifetimeFunction(Token *tok, const TokenList &tokenlist, ErrorLogger &errorLogger, const Settings &settings);
1874

Callers

nothing calls this directly

Calls 6

getParentValueTypesFunction · 0.85
isLifetimeBorrowedFunction · 0.85
isLifetimeOwnedFunction · 0.85
isDifferentTypeFunction · 0.85
astParentMethod · 0.80
strMethod · 0.45

Tested by

no test coverage detected