diff options
author | Anders Carlsson <andersca@mac.com> | 2010-04-24 22:36:50 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-04-24 22:36:50 +0000 |
commit | 6444c417b4e8eaf1893c641f5a246f5adbb761c4 (patch) | |
tree | a6481bd0918a0020ff9b9185db0965ef2eb6efc6 /lib/CodeGen/CGClass.cpp | |
parent | 89fe01900eb7e6832e24d729590d6a51e3eba740 (diff) |
Simplify EmitClassMemberwiseCopy now that it's only used for fields.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102281 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGClass.cpp')
-rw-r--r-- | lib/CodeGen/CGClass.cpp | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index 78a29ad35f..170f965e80 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -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; } |