[Frontend] Infer simulator environment in the frontend, too.

Some code paths that see target triples go through the frontend
without seeing the driver. Therefore, perform the same "simulator"
inference for x86 iOS/tvOS/watchOS triples also in the frontend,
to ensure that we remain compatible. Also make sure that
-print-target-info performs the appropriate adjustment.
This commit is contained in:
Doug Gregor
2020-04-16 21:42:43 -07:00
parent 3e385a83a4
commit b63e9a6bcf
7 changed files with 58 additions and 20 deletions

View File

@@ -553,9 +553,22 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
llvm::Triple Target = Opts.Target;
StringRef TargetArg;
std::string TargetArgScratch;
if (const Arg *A = Args.getLastArg(OPT_target)) {
Target = llvm::Triple(A->getValue());
TargetArg = A->getValue();
// Backward compatibility hack: infer "simulator" environment for x86
// iOS/tvOS/watchOS. The driver takes care of this for the frontend
// most of the time, but loading of old .swiftinterface files goes
// directly to the frontend.
if (tripleInfersSimulatorEnvironment(Target)) {
// Set the simulator environment.
Target.setEnvironment(llvm::Triple::EnvironmentType::Simulator);
TargetArgScratch = Target.str();
TargetArg = TargetArgScratch;
}
}
if (const Arg *A = Args.getLastArg(OPT_target_variant)) {