summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-12-03 22:38:15 +0000
committerMike Stump <mrs@apple.com>2009-12-03 22:38:15 +0000
commit7398ff0f078b1d80a6cb6013cf49c31e3ad1b480 (patch)
treef499b425ef2961bea23ac6d5cbcc67469ec30c43 /clang
parent064d77b7c26c3bf1307d8edffb3e75a77f4a12c2 (diff)
downloadbcm5719-llvm-7398ff0f078b1d80a6cb6013cf49c31e3ad1b480.tar.gz
bcm5719-llvm-7398ff0f078b1d80a6cb6013cf49c31e3ad1b480.zip
Improve catch parameter bindings for scalar non-pointers. WIP.
llvm-svn: 90492
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGException.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index 1ceb2542ae5..93bdf8c8342 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/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);
}
OpenPOWER on IntegriCloud