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

Function getContainerSizeFromConstructor

lib/valueflow.cpp:6598–6610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6596}
6597
6598static std::vector<ValueFlow::Value> getContainerSizeFromConstructor(const Token* tok,
6599 const ValueType* valueType,
6600 const Settings& settings,
6601 bool known = true)
6602{
6603 std::vector<const Token*> args = getArguments(tok);
6604 if (args.empty())
6605 return {makeContainerSizeValue(MathLib::bigint{0}, known)};
6606 // Init list in constructor
6607 if (args.size() == 1 && Token::simpleMatch(args[0], "{"))
6608 return getInitListSize(args[0], valueType, settings, known);
6609 return getContainerSizeFromConstructorArgs(args, valueType->container, known);
6610}
6611
6612static void valueFlowContainerSetTokValue(const TokenList& tokenlist, ErrorLogger& errorLogger, const Settings& settings, const Token* tok, Token* initList)
6613{

Callers 1

valueFlowContainerSizeFunction · 0.85

Calls 7

makeContainerSizeValueFunction · 0.85
getInitListSizeFunction · 0.85
getArgumentsFunction · 0.70
simpleMatchFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected