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

Function isAutoDeallocType

lib/checkleakautovar.cpp:58–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56static const std::array<std::pair<std::string, std::string>, 5> alloc_success_conds {{{"!=", "0"}, {">", "0"}, {"!=", "-1"}, {">=", "0"}, {">", "-1"}}};
57
58static bool isAutoDeallocType(const Type* type) {
59 if (!type || !type->classScope)
60 return true;
61 if (type->classScope->numConstructors > 0)
62 return true;
63 const std::list<Variable>& varlist = type->classScope->varlist;
64 if (std::any_of(varlist.begin(), varlist.end(), [](const Variable& v) {
65 return !v.valueType() || (!v.valueType()->isPrimitive() && !v.valueType()->container);
66 }))
67 return true;
68 if (std::none_of(type->derivedFrom.cbegin(), type->derivedFrom.cend(), [](const Type::BaseInfo& bi) {
69 return isAutoDeallocType(bi.type);
70 }))
71 return false;
72 return true;
73}
74
75/**
76 * @brief Is variable type some class with automatic deallocation?

Callers 1

isAutoDeallocFunction · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected