[cfe-commits] r90492 - /cfe/trunk/lib/CodeGen/CGException.cpp
Mike Stump
mrs at apple.com
Thu Dec 3 14:38:16 PST 2009
Author: mrs
Date: Thu Dec 3 16:38:15 2009
New Revision: 90492
URL: http://llvm.org/viewvc/llvm-project?rev=90492&view=rev
Log:
Improve catch parameter bindings for scalar non-pointers. WIP.
Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=90492&r1=90491&r2=90492&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu Dec 3 16:38:15 2009
@@ -170,12 +170,13 @@
// 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 @@
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 @@
// 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);
}
More information about the cfe-commits
mailing list