[Review, -cxx-abi microsoft] Implement proper handling of virtual destructors (single-inheritance case)
Timur Iskhodzhanov
timurrrr at google.com
Fri Feb 15 06:52:14 PST 2013
2013/2/14 John McCall <rjmccall at apple.com>:
> 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.
Good catch!
For some reason I didn't know there's an implicit conversion from
CanQualType to QualType, hence the awkward attempt to get a Bool
QualType.
Now I just pass Context.BoolTy as a parameter to EmitCXXMemberCall, it
works well and simplifies code.
> Otherwise, this looks great, thanks.
Committed as r175271, thanks for the review!
> John.
More information about the cfe-commits
mailing list