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

Mike Stump mrs at apple.com
Thu Nov 19 16:56:31 PST 2009


Author: mrs
Date: Thu Nov 19 18:56:31 2009
New Revision: 89424

URL: http://llvm.org/viewvc/llvm-project?rev=89424&view=rev
Log:
Add suport for throw;.  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=89424&r1=89423&r2=89424&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu Nov 19 18:56:31 2009
@@ -35,16 +35,28 @@
   std::vector<const llvm::Type*> Args(3, Int8PtrTy);
   
   const llvm::FunctionType *FTy = 
-  llvm::FunctionType::get(llvm::Type::getVoidTy(CGF.getLLVMContext()),
-                          Args, false);
+    llvm::FunctionType::get(llvm::Type::getVoidTy(CGF.getLLVMContext()),
+                            Args, false);
   
   return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_throw");
 }
 
+static llvm::Constant *getReThrowFn(CodeGenFunction &CGF) {
+  // void __cxa_rethrow ();
+
+  const llvm::FunctionType *FTy = 
+    llvm::FunctionType::get(llvm::Type::getVoidTy(CGF.getLLVMContext()), false);
+  
+  return CGF.CGM.CreateRuntimeFunction(FTy, "__cxa_rethrow");
+}
+
 void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) {
-  // FIXME: Handle rethrows.
   if (!E->getSubExpr()) {
-    ErrorUnsupported(E, "rethrow expression");
+    Builder.CreateCall(getReThrowFn(*this))->setDoesNotReturn();
+    Builder.CreateUnreachable();
+
+    // Clear the insertion point to indicate we are in unreachable code.
+    Builder.ClearInsertionPoint();
     return;
   }
   





More information about the cfe-commits mailing list