| 251 | //----------------------------------------------------------------------------- |
| 252 | |
| 253 | static 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 | |
| 281 | static auto* CallVecNew(std::string_view ctorName, Expr* objectParam, QualType allocatedType, Expr* arraySizeExpr) |
no test coverage detected