forked from OSchip/llvm-project
Clean up EmitClassMemberwiseCopy further.
llvm-svn: 102846
This commit is contained in:
parent
820022c55c
commit
ab826ad169
|
@ -593,29 +593,18 @@ static llvm::Value *GetVTTParameter(CodeGenFunction &CGF, GlobalDecl GD) {
|
||||||
/// or via a copy constructor call.
|
/// or via a copy constructor call.
|
||||||
void CodeGenFunction::EmitClassMemberwiseCopy(
|
void CodeGenFunction::EmitClassMemberwiseCopy(
|
||||||
llvm::Value *Dest, llvm::Value *Src,
|
llvm::Value *Dest, llvm::Value *Src,
|
||||||
const CXXRecordDecl *ClassDecl,
|
const CXXRecordDecl *ClassDecl) {
|
||||||
const CXXRecordDecl *BaseClassDecl) {
|
if (ClassDecl->hasTrivialCopyConstructor()) {
|
||||||
CXXCtorType CtorType = Ctor_Complete;
|
EmitAggregateCopy(Dest, Src, getContext().getTagDeclType(ClassDecl));
|
||||||
|
|
||||||
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, getContext().getTagDeclType(BaseClassDecl));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CXXConstructorDecl *BaseCopyCtor =
|
CXXConstructorDecl *CopyCtor = ClassDecl->getCopyConstructor(getContext(), 0);
|
||||||
BaseClassDecl->getCopyConstructor(getContext(), 0);
|
assert(CopyCtor && "Did not have copy ctor!");
|
||||||
if (!BaseCopyCtor)
|
|
||||||
return;
|
|
||||||
|
|
||||||
llvm::Value *VTT = GetVTTParameter(*this, GlobalDecl(BaseCopyCtor, CtorType));
|
llvm::Value *VTT = GetVTTParameter(*this, GlobalDecl(CopyCtor,
|
||||||
EmitCopyCtorCall(*this, BaseCopyCtor, CtorType, Dest, VTT, Src);
|
Ctor_Complete));
|
||||||
|
EmitCopyCtorCall(*this, CopyCtor, Ctor_Complete, Dest, VTT, Src);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitClassCopyAssignment - This routine generates code to copy assign a class
|
/// EmitClassCopyAssignment - This routine generates code to copy assign a class
|
||||||
|
@ -718,7 +707,7 @@ CodeGenFunction::SynthesizeCXXCopyConstructor(const FunctionArgList &Args) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
EmitClassMemberwiseCopy(LHS.getAddress(), RHS.getAddress(),
|
EmitClassMemberwiseCopy(LHS.getAddress(), RHS.getAddress(),
|
||||||
0 /*ClassDecl*/, FieldClassDecl);
|
FieldClassDecl);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -818,8 +818,7 @@ public:
|
||||||
QualType Ty);
|
QualType Ty);
|
||||||
|
|
||||||
void EmitClassMemberwiseCopy(llvm::Value *DestValue, llvm::Value *SrcValue,
|
void EmitClassMemberwiseCopy(llvm::Value *DestValue, llvm::Value *SrcValue,
|
||||||
const CXXRecordDecl *ClassDecl,
|
const CXXRecordDecl *ClassDecl);
|
||||||
const CXXRecordDecl *BaseClassDecl);
|
|
||||||
|
|
||||||
void EmitClassCopyAssignment(llvm::Value *DestValue, llvm::Value *SrcValue,
|
void EmitClassCopyAssignment(llvm::Value *DestValue, llvm::Value *SrcValue,
|
||||||
const CXXRecordDecl *ClassDecl);
|
const CXXRecordDecl *ClassDecl);
|
||||||
|
|
Loading…
Reference in New Issue