MCPcopy Create free account
hub / github.com/andreasfertig/cppinsights / CallVecNewOrCtor

Function CallVecNewOrCtor

CfrontCodeGenerator.cpp:253–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251//-----------------------------------------------------------------------------
252
253static auto* CallVecNewOrCtor(std::string_view ctorName,
254 Expr* objectParam,
255 QualType allocatedType,
256 Expr* arraySizeExpr,
257 std::string_view funName)
258{
259 // According to "Inside the C++ Object Model" the dtor is required in case one of the array element ctors fails the
260 // already constructed one must be destroyed.
261 // See also: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#array-ctor
262 auto dtorName = [&]() {
263 if(HasDtor(allocatedType)) {
264 return GetSpecialMemberName(allocatedType->getAsCXXRecordDecl()->getDestructor());
265 }
266
267 return std::string{kwNull};
268 }();
269
270 SmallVector<Expr*, 6> args{objectParam,
271 Sizeof(allocatedType),
272 arraySizeExpr,
273 Int32(0), // XXX what is the correct value?
274 CastToVoidFunPtr(ctorName),
275 CastToVoidFunPtr(dtorName)};
276
277 return Call(funName, args);
278}
279//-----------------------------------------------------------------------------
280
281static auto* CallVecNew(std::string_view ctorName, Expr* objectParam, QualType allocatedType, Expr* arraySizeExpr)

Callers 2

CallVecNewFunction · 0.85
CallVecCtorFunction · 0.85

Calls 6

HasDtorFunction · 0.85
GetSpecialMemberNameFunction · 0.85
SizeofFunction · 0.85
Int32Function · 0.85
CastToVoidFunPtrFunction · 0.85
CallFunction · 0.70

Tested by

no test coverage detected