Call objc_terminate() instead of abort() when a cleanup throws an
exception in Objective-C;  in Objective-C++ we still use std::terminate().
This is only available in very recent runtimes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134456 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
index 0cce517..74b6591 100644
--- a/lib/Driver/ToolChain.cpp
+++ b/lib/Driver/ToolChain.cpp
@@ -55,12 +55,14 @@
     // Assume a minimal NeXT runtime.
     runtime.HasARC = false;
     runtime.HasWeak = false;
+    runtime.HasTerminate = false;
     return;
 
   case ObjCRuntime::GNU:
     // Assume a maximal GNU runtime.
     runtime.HasARC = true;
     runtime.HasWeak = true;
+    runtime.HasTerminate = false; // to be added
     return;
   }
   llvm_unreachable("invalid runtime kind!");
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 68ebc1b..1619ef8 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -99,6 +99,13 @@
     return ToolChain::configureObjCRuntime(runtime);
 
   runtime.HasARC = runtime.HasWeak = hasARCRuntime();
+
+  // So far, objc_terminate is only available in iOS 5.
+  // FIXME: do the simulator logic properly.
+  if (!ARCRuntimeForSimulator && isTargetIPhoneOS())
+    runtime.HasTerminate = !isIPhoneOSVersionLT(5);
+  else
+    runtime.HasTerminate = false;
 }
 
 // FIXME: Can we tablegen this?
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index d0fd914..d4d41d2 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -1781,6 +1781,8 @@
       CmdArgs.push_back("-fobjc-runtime-has-arc");
     if (objCRuntime.HasWeak)
       CmdArgs.push_back("-fobjc-runtime-has-weak");
+    if (objCRuntime.HasTerminate)
+      CmdArgs.push_back("-fobjc-runtime-has-terminate");
 
     // Compute the Objective-C ABI "version" to use. Version numbers are
     // slightly confusing for historical reasons: