[cfe-commits] r90513 - /cfe/trunk/lib/CodeGen/CGException.cpp

Mike Stump mrs at apple.com
Thu Dec 3 17:51:46 PST 2009


Author: mrs
Date: Thu Dec  3 19:51:45 2009
New Revision: 90513

URL: http://llvm.org/viewvc/llvm-project?rev=90513&view=rev
Log:
Fixup reference binding for catch parameters.
Fixup throws and rethrows to use invoke as appropriate.

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=90513&r1=90512&r2=90513&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu Dec  3 19:51:45 2009
@@ -210,7 +210,13 @@
 
 void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) {
   if (!E->getSubExpr()) {
-    Builder.CreateCall(getReThrowFn(*this))->setDoesNotReturn();
+    if (getInvokeDest()) {
+      llvm::BasicBlock *Cont = createBasicBlock("invoke.cont");
+      Builder.CreateInvoke(getReThrowFn(*this), Cont, getInvokeDest())
+        ->setDoesNotReturn();
+      EmitBlock(Cont);
+    } else
+      Builder.CreateCall(getReThrowFn(*this))->setDoesNotReturn();
     Builder.CreateUnreachable();
 
     // Clear the insertion point to indicate we are in unreachable code.
@@ -237,9 +243,18 @@
   llvm::Constant *TypeInfo = CGM.GenerateRTTI(ThrowType);
   llvm::Constant *Dtor = llvm::Constant::getNullValue(Int8PtrTy);
   
-  llvm::CallInst *ThrowCall = 
-    Builder.CreateCall3(getThrowFn(*this), ExceptionPtr, TypeInfo, Dtor);
-  ThrowCall->setDoesNotReturn();
+  if (getInvokeDest()) {
+    llvm::BasicBlock *Cont = createBasicBlock("invoke.cont");
+    llvm::InvokeInst *ThrowCall = 
+      Builder.CreateInvoke3(getThrowFn(*this), Cont, getInvokeDest(),
+                            ExceptionPtr, TypeInfo, Dtor);
+    ThrowCall->setDoesNotReturn();
+    EmitBlock(Cont);
+  } else {
+    llvm::CallInst *ThrowCall = 
+      Builder.CreateCall3(getThrowFn(*this), ExceptionPtr, TypeInfo, Dtor);
+    ThrowCall->setDoesNotReturn();
+  }
   Builder.CreateUnreachable();
   
   // Clear the insertion point to indicate we are in unreachable code.
@@ -383,7 +398,8 @@
         setInvokeDest(TerminateHandler);
         bool WasPointer = true;
         if (!CatchType.getTypePtr()->isPointerType()) {
-          WasPointer = false;
+          if (!isa<ReferenceType>(CatchParam->getType()))
+            WasPointer = false;
           CatchType = getContext().getPointerType(CatchType);
         }
         ExcObject = Builder.CreateBitCast(ExcObject, ConvertType(CatchType));
@@ -428,7 +444,6 @@
     Builder.CreateInvoke(getEndCatchFn(*this),
                          Cont, TerminateHandler,
                          Args.begin(), Args.begin());
-
     EmitBlock(Cont);
     if (Info.SwitchBlock)
       EmitBlock(Info.SwitchBlock);





More information about the cfe-commits mailing list