From 875ab10245d3bf37252dd822aa1616bb0a391095 Mon Sep 17 00:00:00 2001 From: John McCall Date: Sun, 22 Aug 2010 06:43:33 +0000 Subject: Abstract out member-pointer creation. I'm really unhappy about the current duplication between the constant and non-constant paths in all of this. Implement ARM ABI semantics for member pointer constants and conversion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111772 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprAgg.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'lib/CodeGen/CGExprAgg.cpp') diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 1f8964d0b6..b75aeb13b8 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -364,9 +364,8 @@ void AggExprEmitter::VisitBinComma(const BinaryOperator *E) { void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) { // We have a member function pointer. - const MemberPointerType *MPT = E->getType()->getAs(); - (void) MPT; - assert(MPT->getPointeeType()->isFunctionProtoType() && + assert(E->getType()->getAs() + ->getPointeeType()->isFunctionProtoType() && "Unexpected member pointer type!"); // The creation of member function pointers has no side effects; if @@ -375,20 +374,9 @@ void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) { return; const DeclRefExpr *DRE = cast(E->getSubExpr()); - const CXXMethodDecl *MD = - cast(DRE->getDecl())->getCanonicalDecl(); + const CXXMethodDecl *MD = cast(DRE->getDecl()); - const llvm::Type *PtrDiffTy = - CGF.ConvertType(CGF.getContext().getPointerDiffType()); - - llvm::Value *DstPtr = Builder.CreateStructGEP(DestPtr, 0, "dst.ptr"); - llvm::Value *FuncPtr = CGF.CGM.GetCXXMemberFunctionPointerValue(MD); - Builder.CreateStore(FuncPtr, DstPtr, VolatileDest); - - llvm::Value *AdjPtr = Builder.CreateStructGEP(DestPtr, 1, "dst.adj"); - // The adjustment will always be 0. - Builder.CreateStore(llvm::ConstantInt::get(PtrDiffTy, 0), AdjPtr, - VolatileDest); + CGF.CGM.getCXXABI().EmitMemberFunctionPointer(CGF, MD, DestPtr, VolatileDest); } void AggExprEmitter::VisitStmtExpr(const StmtExpr *E) { -- cgit v1.2.3