diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-08-08 23:32:22 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-08-08 23:32:22 +0000 |
commit | 942f4f33d02dba823594bd2d7b3d317cb01c74f8 (patch) | |
tree | f1507f680daf5b9c6d7638ae0a84de147473fc56 /lib | |
parent | 89ed31d3f9eeb8ec77c284a5cf404a74bf5e7acf (diff) |
ir-gen for initialization, in synthesize copy constructor,
of base/field which have trivial copy constructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78516 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 26 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 3 |
2 files changed, 16 insertions, 13 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index bcae8298e6..82813f51c3 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -761,27 +761,27 @@ llvm::Value *CodeGenFunction::GenerateVtable(const CXXRecordDecl *RD) { /// object from SrcValue to DestValue. Copying can be either a bitwise copy /// of via a copy constructor call. void CodeGenFunction::EmitClassMemberwiseCopy( - llvm::Value *DestValue, llvm::Value *SrcValue, + llvm::Value *Dest, llvm::Value *Src, const CXXRecordDecl *ClassDecl, - const CXXRecordDecl *BaseClassDecl) { - // FIXME. Do bitwise copy of trivial copy constructors. - if (BaseClassDecl->hasTrivialCopyConstructor()) + const CXXRecordDecl *BaseClassDecl, QualType Ty) { + if (ClassDecl) { + Dest = AddressCXXOfBaseClass(Dest, ClassDecl, BaseClassDecl); + Src = AddressCXXOfBaseClass(Src, ClassDecl, BaseClassDecl) ; + } + if (BaseClassDecl->hasTrivialCopyConstructor()) { + EmitAggregateCopy(Dest, Src, Ty); return; + } + if (CXXConstructorDecl *BaseCopyCtor = BaseClassDecl->getCopyConstructor(getContext(), 0)) { llvm::Value *Callee = CGM.GetAddrOfCXXConstructor(BaseCopyCtor, Ctor_Complete); - - llvm::Value *Dest = ClassDecl ? - AddressCXXOfBaseClass(DestValue, ClassDecl, BaseClassDecl) : DestValue; - CallArgList CallArgs; // Push the this (Dest) ptr. CallArgs.push_back(std::make_pair(RValue::get(Dest), BaseCopyCtor->getThisType(getContext()))); - llvm::Value *Src = ClassDecl ? - AddressCXXOfBaseClass(SrcValue, ClassDecl, BaseClassDecl) : SrcValue; // Push the Src ptr. CallArgs.push_back(std::make_pair(RValue::get(Src), BaseCopyCtor->getThisType(getContext()))); @@ -832,7 +832,8 @@ void CodeGenFunction::SynthesizeCXXCopyConstructor(const CXXConstructorDecl *CD, CXXRecordDecl *BaseClassDecl = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl()); - EmitClassMemberwiseCopy(LoadOfThis, LoadOfSrc, ClassDecl, BaseClassDecl); + EmitClassMemberwiseCopy(LoadOfThis, LoadOfSrc, ClassDecl, BaseClassDecl, + Base->getType()); } for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(), @@ -849,8 +850,9 @@ void CodeGenFunction::SynthesizeCXXCopyConstructor(const CXXConstructorDecl *CD, = cast<CXXRecordDecl>(FieldClassType->getDecl()); LValue LHS = EmitLValueForField(LoadOfThis, *Field, false, 0); LValue RHS = EmitLValueForField(LoadOfSrc, *Field, false, 0); + EmitClassMemberwiseCopy(LHS.getAddress(), RHS.getAddress(), - 0 /*ClassDecl*/, FieldClassDecl); + 0 /*ClassDecl*/, FieldClassDecl, FieldType); continue; } // FIXME. Do a built-in assignment of scalar data members. diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index d18217fcc9..5b6826f57f 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -557,7 +557,8 @@ public: void EmitClassMemberwiseCopy(llvm::Value *DestValue, llvm::Value *SrcValue, const CXXRecordDecl *ClassDecl, - const CXXRecordDecl *BaseClassDecl); + const CXXRecordDecl *BaseClassDecl, + QualType Ty); void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type, llvm::Value *This, |