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

Function getLibraryContainer

lib/library.cpp:1981–1999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1979}
1980
1981const Library::Container * getLibraryContainer(const Token * tok)
1982{
1983 if (!tok)
1984 return nullptr;
1985 // TODO: Support dereferencing iterators
1986 // TODO: Support dereferencing with ->
1987 if (tok->isUnaryOp("*") && astIsPointer(tok->astOperand1())) {
1988 for (const ValueFlow::Value& v:tok->astOperand1()->values()) {
1989 if (!v.isLocalLifetimeValue())
1990 continue;
1991 if (v.lifetimeKind != ValueFlow::Value::LifetimeKind::Address)
1992 continue;
1993 return getLibraryContainer(v.tokvalue);
1994 }
1995 }
1996 if (!tok->valueType())
1997 return nullptr;
1998 return tok->valueType()->container;
1999}
2000
2001Library::TypeCheck Library::getTypeCheck(std::string check, std::string typeName) const
2002{

Callers 12

getContainerYieldFunction · 0.85
valueFlowArrayElementFunction · 0.85
getLifetimeTokensFunction · 0.85
valueFlowContainerSizeFunction · 0.85
isWritableMethod · 0.85
writeValueMethod · 0.85
outOfBoundsMethod · 0.85
astIsContainerFunction · 0.85
astIsNonStringContainerFunction · 0.85
astIsContainerViewFunction · 0.85

Calls 3

astIsPointerFunction · 0.85
isUnaryOpMethod · 0.80
astOperand1Method · 0.80

Tested by

no test coverage detected