Revert "More robust deployment target parsing on darwin"

This breaks green-dragon. Revert it and investigate.

llvm-svn: 226011
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index 5677e62..4d97ab3 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -494,28 +494,16 @@
     if (char *env = ::getenv("IPHONEOS_DEPLOYMENT_TARGET"))
       iOSTarget = env;
 
-    // If there is no command-line argument to specify the Target version and
-    // no environment variable defined, see if we can set the default based
-    // on -isysroot.
-    if (iOSTarget.empty() && OSXTarget.empty() &&
-        Args.hasArg(options::OPT_isysroot)) {
+    // If no '-miphoneos-version-min' specified on the command line and
+    // IPHONEOS_DEPLOYMENT_TARGET is not defined, see if we can set the default
+    // based on -isysroot.
+    if (iOSTarget.empty()) {
       if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
+        StringRef first, second;
         StringRef isysroot = A->getValue();
-        // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk
-        size_t BeginSDK = isysroot.rfind("SDKs/");
-        size_t EndSDK = isysroot.rfind(".sdk");
-        if (BeginSDK != StringRef::npos && EndSDK != StringRef::npos) {
-          StringRef SDK = isysroot.slice(BeginSDK + 5, EndSDK);
-          size_t StartVer = SDK.find_first_of("123456789");
-          if (StartVer != StringRef::npos) {
-            StringRef Version = SDK.substr(StartVer);
-            if (SDK.startswith("iPhoneOS") ||
-                SDK.startswith("iPhoneSimulator"))
-              iOSTarget = Version;
-            else if (SDK.startswith("MacOSX"))
-              OSXTarget = Version;
-          }
-        }
+        std::tie(first, second) = isysroot.split(StringRef("SDKs/iPhoneOS"));
+        if (second != "")
+          iOSTarget = second.substr(0,3);
       }
     }