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

Function hasBorrowingVariables

lib/valueflow.cpp:2329–2356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2327};
2328
2329static bool hasBorrowingVariables(const std::list<Variable>& vars, const std::vector<const Token*>& args, int depth = 10)
2330{
2331 if (depth < 0)
2332 return true;
2333 return std::any_of(vars.cbegin(), vars.cend(), [&](const Variable& var) {
2334 if (const ValueType* vt = var.valueType()) {
2335 if (vt->pointer > 0 &&
2336 std::none_of(args.begin(), args.end(), [vt](const Token* arg) {
2337 return arg->valueType() && arg->valueType()->type == vt->type;
2338 }))
2339 return false;
2340 if (vt->pointer > 0)
2341 return true;
2342 if (vt->reference != Reference::None)
2343 return true;
2344 if (vt->isPrimitive())
2345 return false;
2346 if (vt->isEnum())
2347 return false;
2348 // TODO: Check container inner type
2349 if (vt->type == ValueType::CONTAINER && vt->container)
2350 return vt->container->view;
2351 if (vt->typeScope)
2352 return hasBorrowingVariables(vt->typeScope->varlist, args, depth - 1);
2353 }
2354 return true;
2355 });
2356}
2357
2358static void valueFlowLifetimeUserConstructor(Token* tok,
2359 const Function* constructor,

Callers 1

Calls 3

isEnumMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected