]> granicus.if.org Git - clang/commitdiff
[Driver] Simplify code choosing between MacOS and iOS platforms. NFC.
authorAlexey Samsonov <vonosmas@gmail.com>
Thu, 18 Jun 2015 00:36:38 +0000 (00:36 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Thu, 18 Jun 2015 00:36:38 +0000 (00:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239980 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp

index e3dab2040fc6deb390a6c6ca67f55daf0be91dfb..25a3d8e475b302c9ff21e3d8792fd18c81563e85 100644 (file)
@@ -515,13 +515,17 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
       }
     }
 
-    // If no OSX or iOS target has been specified and we're compiling for armv7,
-    // go ahead as assume we're targeting iOS.
-    StringRef MachOArchName = getMachOArchName(Args);
-    if (OSXTarget.empty() && iOSTarget.empty() &&
-        (MachOArchName == "armv7" || MachOArchName == "armv7s" ||
-         MachOArchName == "arm64"))
+    // If no OSX or iOS target has been specified, try to guess platform
+    // from arch name.
+    if (OSXTarget.empty() && iOSTarget.empty()) {
+      StringRef MachOArchName = getMachOArchName(Args);
+      if (MachOArchName == "armv7" || MachOArchName == "armv7s" ||
+          MachOArchName == "arm64")
         iOSTarget = iOSVersionMin;
+      else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
+               MachOArchName != "armv7em")
+        OSXTarget = MacosxVersionMin;
+    }
 
     // Allow conflicts among OSX and iOS for historical reasons, but choose the
     // default platform.
@@ -542,12 +546,6 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
       const Option O = Opts.getOption(options::OPT_miphoneos_version_min_EQ);
       iOSVersion = Args.MakeJoinedArg(nullptr, O, iOSTarget);
       Args.append(iOSVersion);
-    } else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
-               MachOArchName != "armv7em") {
-      // Otherwise, assume we are targeting OS X.
-      const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
-      OSXVersion = Args.MakeJoinedArg(nullptr, O, MacosxVersionMin);
-      Args.append(OSXVersion);
     }
   }