]> granicus.if.org Git - clang/commitdiff
Split the exception object out into its own stack.
authorAnders Carlsson <andersca@mac.com>
Sat, 7 Feb 2009 21:37:21 +0000 (21:37 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 7 Feb 2009 21:37:21 +0000 (21:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64032 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CodeGenFunction.h

index 6c6419e4f17eabcba20f66ab0ca7c4a32c5b2ee9..ba2f5262fd1365466380973fcba89d267436cbb1 100644 (file)
@@ -1868,7 +1868,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
   // through finally.
   CodeGenFunction::ObjCEHEntry EHEntry(FinallyBlock, FinallySwitch, DestCode);
   CGF.ObjCEHStack.push_back(&EHEntry);
-
+  CGF.ObjCEHValueStack.push_back(0);
+  
   // Allocate memory for the exception data and rethrow pointer.
   llvm::Value *ExceptionData = CGF.CreateTempAlloca(ObjCTypes.ExceptionDataTy,
                                                     "exceptiondata.ptr");
@@ -1913,7 +1914,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
   llvm::Value *Caught = CGF.Builder.CreateCall(ObjCTypes.ExceptionExtractFn,
                                                ExceptionData,
                                                "caught");
-  EHEntry.Exception = Caught;
+  CGF.ObjCEHValueStack.back() = Caught;
   if (!isTry)
   {
     CGF.Builder.CreateStore(Caught, RethrowPtr);
@@ -2032,7 +2033,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
   // this now, because the code in the @finally block is not in this
   // context.
   CGF.ObjCEHStack.pop_back();
-
+  CGF.ObjCEHValueStack.pop_back();
+  
   // Emit the @finally block.
   CGF.EmitBlock(FinallyBlock);
   llvm::Value* CallTryExit = CGF.Builder.CreateLoad(CallTryExitPtr, "tmp");
@@ -2076,9 +2078,9 @@ void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
     ExceptionAsObject = 
       CGF.Builder.CreateBitCast(Exception, ObjCTypes.ObjectPtrTy, "tmp");
   } else {
-    assert((!CGF.ObjCEHStack.empty() && CGF.ObjCEHStack.back()->Exception) && 
+    assert((!CGF.ObjCEHValueStack.empty() && CGF.ObjCEHValueStack.back()) && 
            "Unexpected rethrow outside @catch block.");
-    ExceptionAsObject = CGF.ObjCEHStack.back()->Exception;
+    ExceptionAsObject = CGF.ObjCEHValueStack.back();
   }
   
   CGF.Builder.CreateCall(ObjCTypes.ExceptionThrowFn, ExceptionAsObject);
index ce32a45a5d71cdbde14eb3a044f984dfd59fe6d8..9d8d3a3f4a057c575529722ef2250197a5a6b034 100644 (file)
@@ -97,7 +97,7 @@ public:
   struct ObjCEHEntry {
     ObjCEHEntry(llvm::BasicBlock *fb, llvm::SwitchInst *fs, llvm::Value *dc)
       : FinallyBlock(fb), FinallySwitch(fs), 
-        DestCode(dc), Exception(0) {}
+        DestCode(dc) {}
 
     /// Entry point to the finally block.
     llvm::BasicBlock *FinallyBlock; 
@@ -109,12 +109,12 @@ public:
     /// Variable holding the code for the destination of a jump
     /// through the @finally block.
     llvm::Value *DestCode;
-
-    /// The exception object being handled, during IR generation for a
-    /// @catch block.
-    llvm::Value *Exception; 
   };
 
+  /// ObjCEHValueStack - Stack of exception objects being handled,
+  /// during IR generation for a @catch block.
+  llvm::SmallVector<llvm::Value*, 8> ObjCEHValueStack;
+  
   typedef llvm::SmallVector<ObjCEHEntry*, 8> ObjCEHStackType;
   ObjCEHStackType ObjCEHStack;