From 377e5c108bd299930ca8e8cb6ebce1d22dfe35f9 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Fri, 9 Nov 2012 01:59:30 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167603 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ARCMigrate/ARCMT.cpp | 44 -------------- lib/Driver/ToolChains.cpp | 79 ++------------------------ lib/Driver/ToolChains.h | 9 +-- test/Driver/ios-simulator-arcruntime.c | 8 +-- 4 files changed, 11 insertions(+), 129 deletions(-) diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp index 9a8f4925ff..b57d996473 100644 --- a/lib/ARCMigrate/ARCMT.cpp +++ b/lib/ARCMigrate/ARCMT.cpp @@ -147,54 +147,10 @@ public: } // 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) diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 49685c0880..a34751260d 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -82,17 +82,11 @@ bool Darwin::HasNativeLLVMSupport() const { /// 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 @@ void DarwinClang::AddLinkARCArgs(const ArgList &Args, 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 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, } } -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 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { 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 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, 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) diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 3c78365296..8ea466af77 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -185,11 +185,6 @@ private: /// 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 @@ public: } bool isTargetMacOS() const { - return !isTargetIOSSimulator() && - !isTargetIPhoneOS() && - TargetSimulatorVersionFromDefines == VersionTuple(); + return !isTargetIOSSimulator() && !isTargetIPhoneOS(); } bool isTargetInitialized() const { return TargetInitialized; } diff --git a/test/Driver/ios-simulator-arcruntime.c b/test/Driver/ios-simulator-arcruntime.c index 33d34924ce..605df93f49 100644 --- a/test/Driver/ios-simulator-arcruntime.c +++ b/test/Driver/ios-simulator-arcruntime.c @@ -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 -- 2.40.0