]> granicus.if.org Git - clang/commitdiff
Simplify EmitClassMemberwiseCopy now that it's only used for fields.
authorAnders Carlsson <andersca@mac.com>
Sat, 24 Apr 2010 22:36:50 +0000 (22:36 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 24 Apr 2010 22:36:50 +0000 (22:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102281 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGClass.cpp
lib/CodeGen/CodeGenFunction.h

index 78a29ad35f6b9bf69bdba5b3fc8ae22c50a5c76a..170f965e80d98ac4364ca7ed64f13195faef4d31 100644 (file)
@@ -590,33 +590,21 @@ static llvm::Value *GetVTTParameter(CodeGenFunction &CGF, GlobalDecl GD) {
 
                                     
 /// EmitClassMemberwiseCopy - This routine generates code to copy a class
-/// object from SrcValue to DestValue. Copying can be either a bitwise copy
-/// or via a copy constructor call.
-void CodeGenFunction::EmitClassMemberwiseCopy(
-                        llvm::Value *Dest, llvm::Value *Src,
-                        const CXXRecordDecl *ClassDecl,
-                        const CXXRecordDecl *BaseClassDecl, QualType Ty) {
-  CXXCtorType CtorType = Ctor_Complete;
-  
-  if (ClassDecl) {
-    Dest = OldGetAddressOfBaseClass(Dest, ClassDecl, BaseClassDecl);
-    Src = OldGetAddressOfBaseClass(Src, ClassDecl, BaseClassDecl);
-
-    // We want to call the base constructor.
-    CtorType = Ctor_Base;
-  }
-  if (BaseClassDecl->hasTrivialCopyConstructor()) {
-    EmitAggregateCopy(Dest, Src, Ty);
+/// object from SrcValue to DestValue.
+void CodeGenFunction::EmitClassMemberwiseCopy(llvm::Value *Dest, 
+                                              llvm::Value *Src,
+                                              const CXXRecordDecl *ClassDecl) {
+  if (ClassDecl->hasTrivialCopyConstructor()) {
+    EmitAggregateCopy(Dest, Src, getContext().getTagDeclType(ClassDecl));
     return;
   }
 
-  CXXConstructorDecl *BaseCopyCtor =
-    BaseClassDecl->getCopyConstructor(getContext(), 0);
-  if (!BaseCopyCtor)
-    return;
-
-  llvm::Value *VTT = GetVTTParameter(*this, GlobalDecl(BaseCopyCtor, CtorType));
-  EmitCopyCtorCall(*this, BaseCopyCtor, CtorType, Dest, VTT, Src);
+  // FIXME: Does this get the right copy constructor?
+  const CXXConstructorDecl *CopyConstructor = 
+    ClassDecl->getCopyConstructor(getContext(), 0);
+  assert(CopyConstructor && "Did not find copy constructor!");
+  
+  EmitCopyCtorCall(*this, CopyConstructor, Ctor_Complete, Dest, 0, Src);
 }
 
 /// EmitClassCopyAssignment - This routine generates code to copy assign a class
@@ -719,7 +707,7 @@ CodeGenFunction::SynthesizeCXXCopyConstructor(const FunctionArgList &Args) {
       }
       else
         EmitClassMemberwiseCopy(LHS.getAddress(), RHS.getAddress(),
-                                0 /*ClassDecl*/, FieldClassDecl, FieldType);
+                                FieldClassDecl);
       continue;
     }
     
index 576486dee9b9ad2196ae3e42ec4d57c375fc587a..d4f49b344ed6a6d743452466d088bf24991ba876 100644 (file)
@@ -814,9 +814,7 @@ public:
                                    QualType Ty);
 
   void EmitClassMemberwiseCopy(llvm::Value *DestValue, llvm::Value *SrcValue,
-                               const CXXRecordDecl *ClassDecl,
-                               const CXXRecordDecl *BaseClassDecl,
-                               QualType Ty);
+                               const CXXRecordDecl *ClassDecl);
 
   void EmitClassCopyAssignment(llvm::Value *DestValue, llvm::Value *SrcValue,
                                const CXXRecordDecl *ClassDecl,