Fix last patch, catch of reference to non-pointer.
llvm-svn: 92386
This commit is contained in:
parent
5ee041873b
commit
9d44fdb397
|
@ -207,20 +207,21 @@ static void CopyObject(CodeGenFunction &CGF, const Expr *E,
|
||||||
// CopyObject - Utility to copy an object. Calls copy constructor as necessary.
|
// CopyObject - Utility to copy an object. Calls copy constructor as necessary.
|
||||||
// N is casted to the right type.
|
// N is casted to the right type.
|
||||||
static void CopyObject(CodeGenFunction &CGF, QualType ObjectType,
|
static void CopyObject(CodeGenFunction &CGF, QualType ObjectType,
|
||||||
bool WasPointer, bool WasReference, llvm::Value *E,
|
bool WasPointer, bool WasPointerReference,
|
||||||
llvm::Value *N) {
|
llvm::Value *E, llvm::Value *N) {
|
||||||
// Store the throw exception in the exception object.
|
// Store the throw exception in the exception object.
|
||||||
if (WasPointer || !CGF.hasAggregateLLVMType(ObjectType)) {
|
if (WasPointer || !CGF.hasAggregateLLVMType(ObjectType)) {
|
||||||
llvm::Value *Value = E;
|
llvm::Value *Value = E;
|
||||||
if (!WasPointer)
|
if (!WasPointer)
|
||||||
Value = CGF.Builder.CreateLoad(Value);
|
Value = CGF.Builder.CreateLoad(Value);
|
||||||
const llvm::Type *ValuePtrTy = Value->getType()->getPointerTo(0);
|
const llvm::Type *ValuePtrTy = Value->getType()->getPointerTo(0);
|
||||||
if (WasReference) {
|
if (WasPointerReference) {
|
||||||
llvm::Value *Tmp = CGF.CreateTempAlloca(Value->getType(), "catch.param");
|
llvm::Value *Tmp = CGF.CreateTempAlloca(Value->getType(), "catch.param");
|
||||||
CGF.Builder.CreateStore(Value, Tmp);
|
CGF.Builder.CreateStore(Value, Tmp);
|
||||||
Value = Tmp;
|
Value = Tmp;
|
||||||
} else
|
ValuePtrTy = Value->getType()->getPointerTo(0);
|
||||||
N = CGF.Builder.CreateBitCast(N, ValuePtrTy);
|
}
|
||||||
|
N = CGF.Builder.CreateBitCast(N, ValuePtrTy);
|
||||||
CGF.Builder.CreateStore(Value, N);
|
CGF.Builder.CreateStore(Value, N);
|
||||||
} else {
|
} else {
|
||||||
const llvm::Type *Ty = CGF.ConvertType(ObjectType)->getPointerTo(0);
|
const llvm::Type *Ty = CGF.ConvertType(ObjectType)->getPointerTo(0);
|
||||||
|
@ -570,11 +571,12 @@ void CodeGenFunction::EmitCXXTryStmt(const CXXTryStmt &S) {
|
||||||
QualType CatchType = CatchParam->getType().getNonReferenceType();
|
QualType CatchType = CatchParam->getType().getNonReferenceType();
|
||||||
setInvokeDest(TerminateHandler);
|
setInvokeDest(TerminateHandler);
|
||||||
bool WasPointer = true;
|
bool WasPointer = true;
|
||||||
bool WasReference = false;
|
bool WasPointerReference = false;
|
||||||
CatchType = CGM.getContext().getCanonicalType(CatchType);
|
CatchType = CGM.getContext().getCanonicalType(CatchType);
|
||||||
if (isa<ReferenceType>(CatchParam->getType()))
|
if (CatchType.getTypePtr()->isPointerType()) {
|
||||||
WasReference = true;
|
if (isa<ReferenceType>(CatchParam->getType()))
|
||||||
if (!CatchType.getTypePtr()->isPointerType()) {
|
WasPointerReference = true;
|
||||||
|
} else {
|
||||||
if (!isa<ReferenceType>(CatchParam->getType()))
|
if (!isa<ReferenceType>(CatchParam->getType()))
|
||||||
WasPointer = false;
|
WasPointer = false;
|
||||||
CatchType = getContext().getPointerType(CatchType);
|
CatchType = getContext().getPointerType(CatchType);
|
||||||
|
@ -585,7 +587,7 @@ void CodeGenFunction::EmitCXXTryStmt(const CXXTryStmt &S) {
|
||||||
// cleanup doesn't start until after the ctor completes, use a decl
|
// cleanup doesn't start until after the ctor completes, use a decl
|
||||||
// init?
|
// init?
|
||||||
CopyObject(*this, CatchParam->getType().getNonReferenceType(),
|
CopyObject(*this, CatchParam->getType().getNonReferenceType(),
|
||||||
WasPointer, WasReference, ExcObject,
|
WasPointer, WasPointerReference, ExcObject,
|
||||||
GetAddrOfLocalVar(CatchParam));
|
GetAddrOfLocalVar(CatchParam));
|
||||||
setInvokeDest(MatchHandler);
|
setInvokeDest(MatchHandler);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue