diff options
author | Mike Stump <mrs@apple.com> | 2009-12-03 22:38:15 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-12-03 22:38:15 +0000 |
commit | d9cb7e97327e148cfc54db5b991d0925686934fb (patch) | |
tree | 72af2b3a5c4dcf649ef24874e0dc021fdf577672 /lib/CodeGen/CGException.cpp | |
parent | d0014540005f2a5ab837365db6bd40f479406758 (diff) |
Improve catch parameter bindings for scalar non-pointers. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90492 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGException.cpp')
-rw-r--r-- | lib/CodeGen/CGException.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index 1ceb2542ae..93bdf8c834 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -170,12 +170,13 @@ static void CopyObject(CodeGenFunction &CGF, const Expr *E, llvm::Value *N) { // CopyObject - Utility to copy an object. Calls copy constructor as necessary. // N is casted to the right type. static void CopyObject(CodeGenFunction &CGF, QualType ObjectType, - llvm::Value *E, llvm::Value *N) { + bool WasPointer, llvm::Value *E, llvm::Value *N) { // Store the throw exception in the exception object. if (!CGF.hasAggregateLLVMType(ObjectType)) { llvm::Value *Value = E; + if (!WasPointer) + Value = CGF.Builder.CreateLoad(Value); const llvm::Type *ValuePtrTy = Value->getType()->getPointerTo(0); - CGF.Builder.CreateStore(Value, CGF.Builder.CreateBitCast(N, ValuePtrTy)); } else { const llvm::Type *Ty = CGF.ConvertType(ObjectType)->getPointerTo(0); @@ -382,8 +383,11 @@ void CodeGenFunction::EmitCXXTryStmt(const CXXTryStmt &S) { if (CatchParam) { QualType CatchType = CatchParam->getType().getNonReferenceType(); setInvokeDest(TerminateHandler); - if (!CatchType.getTypePtr()->isPointerType()) + bool WasPointer = true; + if (!CatchType.getTypePtr()->isPointerType()) { + WasPointer = false; CatchType = getContext().getPointerType(CatchType); + } ExcObject = Builder.CreateBitCast(ExcObject, ConvertType(CatchType)); EmitLocalBlockVarDecl(*CatchParam); #if 0 @@ -394,7 +398,7 @@ void CodeGenFunction::EmitCXXTryStmt(const CXXTryStmt &S) { // cleanup doesn't start until after the ctor completes, use a decl // init? CopyObject(*this, CatchParam->getType().getNonReferenceType(), - ExcObject, GetAddrOfLocalVar(CatchParam)); + WasPointer, ExcObject, GetAddrOfLocalVar(CatchParam)); #endif setInvokeDest(MatchHandler); } |