From d608cdb7c044365cf4e8764ade1e11e99c176078 Mon Sep 17 00:00:00 2001 From: John McCall Date: Sun, 22 Aug 2010 10:59:02 +0000 Subject: Experiment with using first-class aggregates to represent member function pointers. I find the resulting code to be substantially cleaner, and it makes it very easy to use the same APIs for data member pointers (which I have conscientiously avoided here), and it avoids a plethora of potential inefficiencies due to excessive memory copying, but we'll have to see if it actually works. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111776 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGCXX.cpp | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) (limited to 'lib/CodeGen/CGCXX.cpp') diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 2d7b27b18b..b805d136c4 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -330,6 +330,11 @@ static void ErrorUnsupportedABI(CodeGenFunction &CGF, << S; } +static llvm::Constant *GetBogusMemberPointer(CodeGenModule &CGM, + QualType T) { + return llvm::Constant::getNullValue(CGM.getTypes().ConvertType(T)); +} + llvm::Value *CGCXXABI::EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF, llvm::Value *&This, llvm::Value *MemPtr, @@ -341,32 +346,16 @@ llvm::Value *CGCXXABI::EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF, const CXXRecordDecl *RD = cast(MPT->getClass()->getAs()->getDecl()); const llvm::FunctionType *FTy = - CGF.CGM.getTypes().GetFunctionType( - CGF.CGM.getTypes().getFunctionInfo(RD, FPT), - FPT->isVariadic()); + CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(RD, FPT), + FPT->isVariadic()); return llvm::Constant::getNullValue(FTy->getPointerTo()); } -void CGCXXABI::EmitMemberFunctionPointerConversion(CodeGenFunction &CGF, - const CastExpr *E, - llvm::Value *Src, - llvm::Value *Dest, - bool VolatileDest) { +llvm::Value *CGCXXABI::EmitMemberFunctionPointerConversion(CodeGenFunction &CGF, + const CastExpr *E, + llvm::Value *Src) { ErrorUnsupportedABI(CGF, "member function pointer conversions"); -} - -void CGCXXABI::EmitNullMemberFunctionPointer(CodeGenFunction &CGF, - const MemberPointerType *MPT, - llvm::Value *Dest, - bool VolatileDest) { - ErrorUnsupportedABI(CGF, "null member function pointers"); -} - -void CGCXXABI::EmitMemberFunctionPointer(CodeGenFunction &CGF, - const CXXMethodDecl *MD, - llvm::Value *DestPtr, - bool VolatileDest) { - ErrorUnsupportedABI(CGF, "member function pointers"); + return GetBogusMemberPointer(CGM, E->getType()); } llvm::Value * @@ -390,16 +379,18 @@ CGCXXABI::EmitMemberFunctionPointerIsNotNull(CodeGenFunction &CGF, llvm::Constant * CGCXXABI::EmitMemberFunctionPointerConversion(llvm::Constant *C, const CastExpr *E) { - return 0; + return GetBogusMemberPointer(CGM, E->getType()); } llvm::Constant * CGCXXABI::EmitNullMemberFunctionPointer(const MemberPointerType *MPT) { - return 0; + return GetBogusMemberPointer(CGM, QualType(MPT, 0)); } llvm::Constant *CGCXXABI::EmitMemberFunctionPointer(const CXXMethodDecl *MD) { - return 0; + return GetBogusMemberPointer(CGM, + CGM.getContext().getMemberPointerType(MD->getType(), + MD->getParent()->getTypeForDecl())); } bool CGCXXABI::RequiresNonZeroInitializer(QualType T) { -- cgit v1.2.3-70-g09d2