diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChains/Darwin.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChains/Darwin.h | 3 | ||||
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 5 |
5 files changed, 15 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 6c47da8ab99..ef4e6cd4f01 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -4885,10 +4885,7 @@ void CGObjCCommonMac::EmitImageInfo() { } // Indicate whether we're compiling this to run on a simulator. - const llvm::Triple &Triple = CGM.getTarget().getTriple(); - if ((Triple.isiOS() || Triple.isWatchOS()) && - (Triple.getArch() == llvm::Triple::x86 || - Triple.getArch() == llvm::Triple::x86_64)) + if (CGM.getTarget().getTriple().isSimulatorEnvironment()) Mod.addModuleFlag(llvm::Module::Error, "Objective-C Is Simulated", eImageInfo_ImageIsSimulated); diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 328b88559b7..f96a1182e3c 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -81,6 +81,12 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, getFilePaths().push_back(CandidateLibPath); } +void ToolChain::setTripleEnvironment(llvm::Triple::EnvironmentType Env) { + Triple.setEnvironment(Env); + if (EffectiveTriple != llvm::Triple()) + EffectiveTriple.setEnvironment(Env); +} + ToolChain::~ToolChain() { } diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 7c401aa9dd5..2b0e59a6b59 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1214,14 +1214,6 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { if (iOSVersion) ExplicitIOSDeploymentTargetStr = iOSVersion->getAsString(Args); - // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y and - // -m(iphone|tv|watch)simulator-version-min=X.Y. - if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ) || - Args.hasArg(options::OPT_mtvos_simulator_version_min_EQ) || - Args.hasArg(options::OPT_mwatchos_simulator_version_min_EQ)) - Args.append(Args.MakeSeparateArg(nullptr, Opts.getOption(options::OPT_D), - " __APPLE_EMBEDDED_SIMULATOR__=1")); - if (OSXVersion && (iOSVersion || TvOSVersion || WatchOSVersion)) { getDriver().Diag(diag::err_drv_argument_not_allowed_with) << OSXVersion->getAsString(Args) diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h index c861f172fe1..6d6493a6d1b 100644 --- a/clang/lib/Driver/ToolChains/Darwin.h +++ b/clang/lib/Driver/ToolChains/Darwin.h @@ -329,6 +329,9 @@ protected: TargetInitialized = true; TargetPlatform = Platform; TargetVersion = VersionTuple(Major, Minor, Micro); + if (Platform == IPhoneOSSimulator || Platform == TvOSSimulator || + Platform == WatchOSSimulator) + const_cast<Darwin *>(this)->setTripleEnvironment(llvm::Triple::Simulator); } bool isTargetIPhoneOS() const { diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 617b6aabcc7..a7ce2868a63 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -998,6 +998,11 @@ static void InitializePredefinedMacros(const TargetInfo &TI, Builder.defineMacro("__nullable", "_Nullable"); } + // Add a macro to differentiate between regular iOS/tvOS/watchOS targets and + // the corresponding simulator targets. + if (TI.getTriple().isOSDarwin() && TI.getTriple().isSimulatorEnvironment()) + Builder.defineMacro("__APPLE_EMBEDDED_SIMULATOR__", "1"); + // OpenMP definition // OpenMP 2.2: // In implementations that support a preprocessor, the _OPENMP |