[Review, -cxx-abi microsoft] Implement proper handling of virtual destructors (single-inheritance case)

John McCall rjmccall at apple.com
Wed Feb 13 15:11:16 PST 2013


On Feb 13, 2013, at 9:43 AM, Timur Iskhodzhanov <timurrrr at google.com> wrote:
> Attached is the patch that abstracts out emitting the vdtor calls and
> does that correctly in Microsoft ABI (that's "part 2").

+RValue MicrosoftCXXABI::EmitVirtualDestructorCall(CodeGenFunction &CGF,
+                                                  const CXXDestructorDecl *Dtor,
+                                                  CXXDtorType DtorType,
+                                                  SourceLocation CallLoc,
+                                                  ReturnValueSlot ReturnValue,
+                                                  llvm::Value *This) {
+  assert(DtorType == Dtor_Deleting || DtorType == Dtor_Complete);
+
+  // We have only one destructor in the vftable but can get both behaviors
+  // by passing an implicit bool parameter.
+  const CGFunctionInfo *FInfo
+      = &CGM.getTypes().arrangeCXXDestructor(Dtor, Dtor_Deleting);
+  llvm::Type *Ty = CGF.CGM.getTypes().GetFunctionType(*FInfo);
+  llvm::Value *Callee = CGF.BuildVirtualCall(Dtor, Dtor_Deleting, This, Ty);
+
+  ASTContext &Context = CGF.getContext();
+  llvm::Value *ImplicitParam
+    = llvm::ConstantInt::get(llvm::IntegerType::getInt1Ty(CGF.getLLVMContext()),
+                             DtorType == Dtor_Deleting);
+  QualType ImplicitParamTy = Context.getPointerType(Context.BoolTy);

I think you want bool, not bool*.  Certainly the parameter you're passing
is just a bool.

Otherwise, this looks great, thanks.

John.



More information about the cfe-commits mailing list