[cfe-commits] r167603 - in /cfe/trunk: lib/ARCMigrate/ARCMT.cpp lib/Driver/ToolChains.cpp lib/Driver/ToolChains.h test/Driver/ios-simulator-arcruntime.c

Bob Wilson bob.wilson at apple.com
Thu Nov 8 17:59:30 PST 2012


Author: bwilson
Date: Thu Nov  8 19:59:30 2012
New Revision: 167603

URL: http://llvm.org/viewvc/llvm-project?rev=167603&view=rev
Log:
Remove old driver code to grab the iOS simulator version from the -D option.

We can now rely on the -mios-simulator-version-min command line option
and remove the awful hack. <rdar://problem/10304510>

Modified:
    cfe/trunk/lib/ARCMigrate/ARCMT.cpp
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/ToolChains.h
    cfe/trunk/test/Driver/ios-simulator-arcruntime.c

Modified: cfe/trunk/lib/ARCMigrate/ARCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ARCMT.cpp?rev=167603&r1=167602&r2=167603&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ARCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ARCMT.cpp Thu Nov  8 19:59:30 2012
@@ -147,54 +147,10 @@
 
 } // end anonymous namespace
 
-static inline StringRef SimulatorVersionDefineName() {
-  return "__IPHONE_OS_VERSION_MIN_REQUIRED=";
-}
-
-/// \brief Parse the simulator version define:
-/// __IPHONE_OS_VERSION_MIN_REQUIRED=([0-9])([0-9][0-9])([0-9][0-9])
-// and return the grouped values as integers, e.g:
-//   __IPHONE_OS_VERSION_MIN_REQUIRED=40201
-// will return Major=4, Minor=2, Micro=1.
-static bool GetVersionFromSimulatorDefine(StringRef define,
-                                          unsigned &Major, unsigned &Minor,
-                                          unsigned &Micro) {
-  assert(define.startswith(SimulatorVersionDefineName()));
-  StringRef name, version;
-  llvm::tie(name, version) = define.split('=');
-  if (version.empty())
-    return false;
-  std::string verstr = version.str();
-  char *end;
-  unsigned num = (unsigned) strtol(verstr.c_str(), &end, 10);
-  if (*end != '\0')
-    return false;
-  Major = num / 10000;
-  num = num % 10000;
-  Minor = num / 100;
-  Micro = num % 100;
-  return true;
-}
-
 static bool HasARCRuntime(CompilerInvocation &origCI) {
   // This duplicates some functionality from Darwin::AddDeploymentTarget
   // but this function is well defined, so keep it decoupled from the driver
   // and avoid unrelated complications.
-
-  for (unsigned i = 0, e = origCI.getPreprocessorOpts().Macros.size();
-         i != e; ++i) {
-    StringRef define = origCI.getPreprocessorOpts().Macros[i].first;
-    bool isUndef = origCI.getPreprocessorOpts().Macros[i].second;
-    if (isUndef)
-      continue;
-    if (!define.startswith(SimulatorVersionDefineName()))
-      continue;
-    unsigned Major = 0, Minor = 0, Micro = 0;
-    if (GetVersionFromSimulatorDefine(define, Major, Minor, Micro) &&
-        Major < 10 && Minor < 100 && Micro < 100)
-      return Major >= 5;
-  }
-
   llvm::Triple triple(origCI.getTargetOpts().Triple);
 
   if (triple.getOS() == llvm::Triple::IOS)

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=167603&r1=167602&r2=167603&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Nov  8 19:59:30 2012
@@ -82,17 +82,11 @@
 
 /// Darwin provides an ARC runtime starting in MacOS X 10.7 and iOS 5.0.
 ObjCRuntime Darwin::getDefaultObjCRuntime(bool isNonFragile) const {
-  if (isTargetIPhoneOS()) {
+  if (isTargetIPhoneOS())
     return ObjCRuntime(ObjCRuntime::iOS, TargetVersion);
-  } else if (TargetSimulatorVersionFromDefines != VersionTuple()) {
-    return ObjCRuntime(ObjCRuntime::iOS, TargetSimulatorVersionFromDefines);
-  } else {
-    if (isNonFragile) {
-      return ObjCRuntime(ObjCRuntime::MacOSX, TargetVersion);
-    } else {
-      return ObjCRuntime(ObjCRuntime::FragileMacOSX, TargetVersion);
-    }
-  }
+  if (isNonFragile)
+    return ObjCRuntime(ObjCRuntime::MacOSX, TargetVersion);
+  return ObjCRuntime(ObjCRuntime::FragileMacOSX, TargetVersion);
 }
 
 /// Darwin provides a blocks runtime starting in MacOS X 10.6 and iOS 3.2.
@@ -250,9 +244,6 @@
     s += "iphonesimulator";
   else if (isTargetIPhoneOS())
     s += "iphoneos";
-  // FIXME: Remove this once we depend fully on -mios-simulator-version-min.
-  else if (TargetSimulatorVersionFromDefines != VersionTuple())
-    s += "iphonesimulator";
   else
     s += "macosx";
   s += ".a";
@@ -376,35 +367,6 @@
   }
 }
 
-static inline StringRef SimulatorVersionDefineName() {
-  return "__IPHONE_OS_VERSION_MIN_REQUIRED";
-}
-
-/// \brief Parse the simulator version define:
-/// __IPHONE_OS_VERSION_MIN_REQUIRED=([0-9])([0-9][0-9])([0-9][0-9])
-// and return the grouped values as integers, e.g:
-//   __IPHONE_OS_VERSION_MIN_REQUIRED=40201
-// will return Major=4, Minor=2, Micro=1.
-static bool GetVersionFromSimulatorDefine(StringRef define,
-                                          unsigned &Major, unsigned &Minor,
-                                          unsigned &Micro) {
-  assert(define.startswith(SimulatorVersionDefineName()));
-  StringRef name, version;
-  llvm::tie(name, version) = define.split('=');
-  if (version.empty())
-    return false;
-  std::string verstr = version.str();
-  char *end;
-  unsigned num = (unsigned) strtol(verstr.c_str(), &end, 10);
-  if (*end != '\0')
-    return false;
-  Major = num / 10000;
-  num = num % 10000;
-  Minor = num / 100;
-  Micro = num % 100;
-  return true;
-}
-
 void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
   const OptTable &Opts = getDriver().getOpts();
 
@@ -427,30 +389,6 @@
   Arg *iOSSimVersion = Args.getLastArg(
     options::OPT_mios_simulator_version_min_EQ);
 
-  // FIXME: HACK! When compiling for the simulator we don't get a
-  // '-miphoneos-version-min' to help us know whether there is an ARC runtime
-  // or not; try to parse a __IPHONE_OS_VERSION_MIN_REQUIRED
-  // define passed in command-line.
-  if (!iOSVersion && !iOSSimVersion) {
-    for (arg_iterator it = Args.filtered_begin(options::OPT_D),
-           ie = Args.filtered_end(); it != ie; ++it) {
-      StringRef define = (*it)->getValue();
-      if (define.startswith(SimulatorVersionDefineName())) {
-        unsigned Major = 0, Minor = 0, Micro = 0;
-        if (GetVersionFromSimulatorDefine(define, Major, Minor, Micro) &&
-            Major < 10 && Minor < 100 && Micro < 100) {
-          TargetSimulatorVersionFromDefines = VersionTuple(Major, Minor, Micro);
-        }
-        // When using the define to indicate the simulator, we force
-        // 10.6 macosx target.
-        const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
-        OSXVersion = Args.MakeJoinedArg(0, O, "10.6");
-        Args.append(OSXVersion);
-        break;
-      }
-    }
-  }
-
   if (OSXVersion && (iOSVersion || iOSSimVersion)) {
     getDriver().Diag(diag::err_drv_argument_not_allowed_with)
           << OSXVersion->getAsString(Args)
@@ -895,13 +833,8 @@
     StringRef where;
 
     // Complain about targetting iOS < 5.0 in any way.
-    if (TargetSimulatorVersionFromDefines != VersionTuple()) {
-      if (TargetSimulatorVersionFromDefines < VersionTuple(5, 0))
-        where = "iOS 5.0";
-    } else if (isTargetIPhoneOS()) {
-      if (isIPhoneOSVersionLT(5, 0))
-        where = "iOS 5.0";
-    }
+    if (isTargetIPhoneOS() && isIPhoneOSVersionLT(5, 0))
+      where = "iOS 5.0";
 
     if (where != StringRef()) {
       getDriver().Diag(clang::diag::err_drv_invalid_libcxx_deployment)

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=167603&r1=167602&r2=167603&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Thu Nov  8 19:59:30 2012
@@ -185,11 +185,6 @@
   /// The OS version we are targeting.
   mutable VersionTuple TargetVersion;
 
-protected:
-  // FIXME: Remove this once there is a proper way to detect an ARC runtime
-  // for the simulator.
-  mutable VersionTuple TargetSimulatorVersionFromDefines;
-
 private:
   /// The default macosx-version-min of this tool chain; empty until
   /// initialized.
@@ -243,9 +238,7 @@
   }
 
   bool isTargetMacOS() const {
-    return !isTargetIOSSimulator() &&
-           !isTargetIPhoneOS() &&
-           TargetSimulatorVersionFromDefines == VersionTuple();
+    return !isTargetIOSSimulator() && !isTargetIPhoneOS();
   }
 
   bool isTargetInitialized() const { return TargetInitialized; }

Modified: cfe/trunk/test/Driver/ios-simulator-arcruntime.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ios-simulator-arcruntime.c?rev=167603&r1=167602&r2=167603&view=diff
==============================================================================
--- cfe/trunk/test/Driver/ios-simulator-arcruntime.c (original)
+++ cfe/trunk/test/Driver/ios-simulator-arcruntime.c Thu Nov  8 19:59:30 2012
@@ -1,8 +1,8 @@
-// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=40201 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
-// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -mios-simulator-version-min=4.2.1 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
+// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -mios-simulator-version-min=5.0.0 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
 // 
 
-// CHECK-OPTIONS1: i386-apple-macosx10.6.0
+// CHECK-OPTIONS1: i386-apple-ios4.2.1
 // CHECK-OPTIONS1: -fobjc-runtime=ios-4.2.1
-// CHECK-OPTIONS2: i386-apple-macosx10.6.0
+// CHECK-OPTIONS2: i386-apple-ios5.0.0
 // CHECK-OPTIONS2: -fobjc-runtime=ios-5.0.0





More information about the cfe-commits mailing list