};
using DarwinPlatformKind = Darwin::DarwinPlatformKind;
+ using DarwinEnvironmentKind = Darwin::DarwinEnvironmentKind;
DarwinPlatformKind getPlatform() const { return Platform; }
+ DarwinEnvironmentKind getEnvironment() const { return Environment; }
+
StringRef getOSVersion() const {
if (Kind == OSVersionArg)
return Argument->getValue();
}
static DarwinPlatform createFromTarget(llvm::Triple::OSType OS,
- StringRef OSVersion, Arg *A) {
- return DarwinPlatform(TargetArg, getPlatformFromOS(OS), OSVersion, A);
+ StringRef OSVersion, Arg *A,
+ llvm::Triple::EnvironmentType Env) {
+ DarwinPlatform Result(TargetArg, getPlatformFromOS(OS), OSVersion, A);
+ switch (Env) {
+ case llvm::Triple::Simulator:
+ Result.Environment = DarwinEnvironmentKind::Simulator;
+ break;
+ default:
+ break;
+ }
+ return Result;
}
static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform,
Arg *A) {
SourceKind Kind;
DarwinPlatformKind Platform;
+ DarwinEnvironmentKind Environment = DarwinEnvironmentKind::NativeEnvironment;
std::string OSVersion;
Arg *Argument;
StringRef EnvVarName;
return None;
std::string OSVersion = getOSVersion(Triple.getOS(), Triple, TheDriver);
return DarwinPlatform::createFromTarget(Triple.getOS(), OSVersion,
- Args.getLastArg(options::OPT_target));
+ Args.getLastArg(options::OPT_target),
+ Triple.getEnvironment());
}
} // namespace
} else
llvm_unreachable("unknown kind of Darwin platform");
- DarwinEnvironmentKind Environment = NativeEnvironment;
+ DarwinEnvironmentKind Environment = OSTarget->getEnvironment();
// Recognize iOS targets with an x86 architecture as the iOS simulator.
- if (Platform != MacOS && (getTriple().getArch() == llvm::Triple::x86 ||
- getTriple().getArch() == llvm::Triple::x86_64))
+ if (Environment == NativeEnvironment && Platform != MacOS &&
+ (getTriple().getArch() == llvm::Triple::x86 ||
+ getTriple().getArch() == llvm::Triple::x86_64))
Environment = Simulator;
setTarget(Platform, Environment, Major, Minor, Micro);
// RUN: %clang -target uknown-apple-macos10.11.2 -arch=armv7k -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-TIGNORE-ARCH1 %s
// CHECK-VERSION-TIGNORE-ARCH1: "unknown-apple-macosx10.11.2"
+
+// Target can be used to specify the environment:
+
+// RUN: %clang -target x86_64-apple-ios11-simulator -c %s -### 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-TENV-SIM1 %s
+// CHECK-VERSION-TENV-SIM1: "x86_64-apple-ios11.0.0-simulator"
+
+// RUN: %clang -target armv7k-apple-ios10.1-simulator -c %s -### 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-TENV-SIM2 %s
+// CHECK-VERSION-TENV-SIM2: "thumbv7k-apple-ios10.1.0-simulator"