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
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 2d7b27b..b805d13 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -330,6 +330,11 @@
     << 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 @@
   const CXXRecordDecl *RD = 
     cast<CXXRecordDecl>(MPT->getClass()->getAs<RecordType>()->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 @@
 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) {