[cfe-commits] r93546 - in /cfe/trunk: lib/CodeGen/CGClass.cpp test/CodeGenCXX/copy-assign-synthesis-3.cpp
Eli Friedman
eli.friedman at gmail.com
Fri Jan 15 12:06:12 PST 2010
Author: efriedma
Date: Fri Jan 15 14:06:11 2010
New Revision: 93546
URL: http://llvm.org/viewvc/llvm-project?rev=93546&view=rev
Log:
Fix a couple bugs in copy assignment operator synthesis.
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/test/CodeGenCXX/copy-assign-synthesis-3.cpp
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=93546&r1=93545&r2=93546&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Jan 15 14:06:11 2010
@@ -394,10 +394,8 @@
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 @@
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 @@
}
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 @@
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),
Modified: cfe/trunk/test/CodeGenCXX/copy-assign-synthesis-3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/copy-assign-synthesis-3.cpp?rev=93546&r1=93545&r2=93546&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/copy-assign-synthesis-3.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/copy-assign-synthesis-3.cpp Fri Jan 15 14:06:11 2010
@@ -1,18 +1,24 @@
// RUN: %clang_cc1 -emit-llvm-only -verify %s
struct A {
- A& operator=(const A&);
+ A& operator=(A&);
};
struct B {
+ void operator=(B);
+};
+
+struct C {
A a;
- float b;
- int (A::*c)();
- _Complex float d;
- int e[10];
- A f[2];
+ B b;
+ float c;
+ int (A::*d)();
+ _Complex float e;
+ int f[10];
+ A g[2];
+ B h[2];
};
-void a(B& x, B& y) {
+void a(C& x, C& y) {
x = y;
}
More information about the cfe-commits
mailing list