Coding by inspection has its problems.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116672 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index acb3ece..72953ce 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -6167,6 +6167,8 @@
                                            const ObjCAtThrowStmt &S) {
   if (const Expr *ThrowExpr = S.getThrowExpr()) {
     llvm::Value *Exception = CGF.EmitScalarExpr(ThrowExpr);
+    Exception = CGF.Builder.CreateBitCast(Exception, ObjCTypes.ObjectPtrTy,
+                                          "tmp");
     llvm::Value *Args[] = { Exception };
     CGF.EmitCallOrInvoke(ObjCTypes.getExceptionThrowFn(),
                          Args, Args+1)
diff --git a/test/CodeGenObjC/exceptions-nonfragile.m b/test/CodeGenObjC/exceptions-nonfragile.m
index 41cda2c..57ed1d9 100644
--- a/test/CodeGenObjC/exceptions-nonfragile.m
+++ b/test/CodeGenObjC/exceptions-nonfragile.m
@@ -11,3 +11,7 @@
     @throw;
   }
 }
+
+void throwing() {
+  @throw(@"error!");
+}