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

Function isLifetimeBorrowed

lib/valueflow.cpp:1753–1778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1751}
1752
1753static bool isLifetimeBorrowed(const ValueType *vt, const ValueType *vtParent)
1754{
1755 if (!vtParent)
1756 return false;
1757 if (!vt)
1758 return false;
1759 if (vt->pointer > 0 && vt->pointer == vtParent->pointer)
1760 return true;
1761 if (vtParent->container && vtParent->container->view)
1762 return true;
1763 if (vt->type != ValueType::UNKNOWN_TYPE && vtParent->type != ValueType::UNKNOWN_TYPE && vtParent->container == vt->container) {
1764 if (vtParent->pointer > vt->pointer)
1765 return true;
1766 if (vtParent->pointer < vt->pointer && vtParent->isIntegral())
1767 return true;
1768 ValueType temp = *vtParent;
1769 if ((temp.constness & 1) && !(vt->constness & 1)) // allow assignment to const/volatile
1770 temp.constness &= ~1;
1771 if ((temp.volatileness & 1) && !(vt->volatileness & 1))
1772 temp.volatileness &= ~1;
1773 if (temp.str() == vt->str())
1774 return true;
1775 }
1776
1777 return false;
1778}
1779
1780static const Token* skipCVRefs(const Token* tok, const Token* endTok)
1781{

Callers 7

setTokenValueFunction · 0.85
isLifetimeBorrowedMethod · 0.85
valueFlowForwardLifetimeFunction · 0.85
checkVarLifetimeScopeMethod · 0.85

Calls 2

isIntegralMethod · 0.80
strMethod · 0.45

Tested by

no test coverage detected