]> granicus.if.org Git - clang/commitdiff
Add suport for throw;. WIP.
authorMike Stump <mrs@apple.com>
Fri, 20 Nov 2009 00:56:31 +0000 (00:56 +0000)
committerMike Stump <mrs@apple.com>
Fri, 20 Nov 2009 00:56:31 +0000 (00:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89424 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGException.cpp

index 93f3eb9f7c5a65b86363843e3d281612056b9a3b..3abc40775a8ae8e20949681e9f7c62eedf8efa35 100644 (file)
@@ -35,16 +35,28 @@ static llvm::Constant *getThrowFn(CodeGenFunction &CGF) {
   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;
   }