Fix a couple bugs in copy assignment operator synthesis.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93546 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eli Friedman 2010-01-15 20:06:11 +00:00
Родитель 5467b208d5
Коммит 8a850baa41
2 изменённых файлов: 26 добавлений и 20 удалений

Просмотреть файл

@ -394,10 +394,8 @@ void CodeGenFunction::EmitClassAggrCopyAssignment(llvm::Value *Dest,
if (BitwiseAssign)
EmitAggregateCopy(Dest, Src, Ty);
else {
bool hasCopyAssign = BaseClassDecl->hasConstCopyAssignment(getContext(),
MD);
assert(hasCopyAssign && "EmitClassAggrCopyAssignment - No user assign");
(void)hasCopyAssign;
BaseClassDecl->hasConstCopyAssignment(getContext(), MD);
assert(MD && "EmitClassAggrCopyAssignment - No user assign");
const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
const llvm::Type *LTy =
CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
@ -410,8 +408,10 @@ void CodeGenFunction::EmitClassAggrCopyAssignment(llvm::Value *Dest,
MD->getThisType(getContext())));
// Push the Src ptr.
CallArgs.push_back(std::make_pair(RValue::get(Src),
MD->getParamDecl(0)->getType()));
QualType SrcTy = MD->getParamDecl(0)->getType();
RValue SrcValue = SrcTy->isReferenceType() ? RValue::get(Src) :
RValue::getAggregate(Src);
CallArgs.push_back(std::make_pair(SrcValue, SrcTy));
QualType ResultType = MD->getType()->getAs<FunctionType>()->getResultType();
EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs),
Callee, ReturnValueSlot(), CallArgs, MD);
@ -531,10 +531,8 @@ void CodeGenFunction::EmitClassCopyAssignment(
}
const CXXMethodDecl *MD = 0;
bool ConstCopyAssignOp = BaseClassDecl->hasConstCopyAssignment(getContext(),
MD);
assert(ConstCopyAssignOp && "EmitClassCopyAssignment - missing copy assign");
(void)ConstCopyAssignOp;
BaseClassDecl->hasConstCopyAssignment(getContext(), MD);
assert(MD && "EmitClassCopyAssignment - missing copy assign");
const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
const llvm::Type *LTy =
@ -548,8 +546,10 @@ void CodeGenFunction::EmitClassCopyAssignment(
MD->getThisType(getContext())));
// Push the Src ptr.
CallArgs.push_back(std::make_pair(RValue::get(Src),
MD->getParamDecl(0)->getType()));
QualType SrcTy = MD->getParamDecl(0)->getType();
RValue SrcValue = SrcTy->isReferenceType() ? RValue::get(Src) :
RValue::getAggregate(Src);
CallArgs.push_back(std::make_pair(SrcValue, SrcTy));
QualType ResultType =
MD->getType()->getAs<FunctionType>()->getResultType();
EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs),

Просмотреть файл

@ -1,18 +1,24 @@
// RUN: %clang_cc1 -emit-llvm-only -verify %s
struct A {
A& operator=(const A&);
A& operator=(A&);
};
struct B {
A a;
float b;
int (A::*c)();
_Complex float d;
int e[10];
A f[2];
void operator=(B);
};
void a(B& x, B& y) {
struct C {
A a;
B b;
float c;
int (A::*d)();
_Complex float e;
int f[10];
A g[2];
B h[2];
};
void a(C& x, C& y) {
x = y;
}