r367350 - [NFC] simplify Darwin environment handling
JF Bastien via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 30 13:01:46 PDT 2019
Author: jfb
Date: Tue Jul 30 13:01:46 2019
New Revision: 367350
URL: http://llvm.org/viewvc/llvm-project?rev=367350&view=rev
Log:
[NFC] simplify Darwin environment handling
The previous code detected conflicts through copy-pasta, this versions
uses a 'loop'.
Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=367350&r1=367349&r2=367350&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Jul 30 13:01:46 2019
@@ -1480,22 +1480,6 @@ getDeploymentTargetFromEnvironmentVariab
Targets[I.index()] = Env;
}
- // Do not allow conflicts with the watchOS target.
- if (!Targets[Darwin::WatchOS].empty() &&
- (!Targets[Darwin::IPhoneOS].empty() || !Targets[Darwin::TvOS].empty())) {
- TheDriver.Diag(diag::err_drv_conflicting_deployment_targets)
- << "WATCHOS_DEPLOYMENT_TARGET"
- << (!Targets[Darwin::IPhoneOS].empty() ? "IPHONEOS_DEPLOYMENT_TARGET"
- : "TVOS_DEPLOYMENT_TARGET");
- }
-
- // Do not allow conflicts with the tvOS target.
- if (!Targets[Darwin::TvOS].empty() && !Targets[Darwin::IPhoneOS].empty()) {
- TheDriver.Diag(diag::err_drv_conflicting_deployment_targets)
- << "TVOS_DEPLOYMENT_TARGET"
- << "IPHONEOS_DEPLOYMENT_TARGET";
- }
-
// Allow conflicts among OSX and iOS for historical reasons, but choose the
// default platform.
if (!Targets[Darwin::MacOS].empty() &&
@@ -1508,6 +1492,18 @@ getDeploymentTargetFromEnvironmentVariab
else
Targets[Darwin::IPhoneOS] = Targets[Darwin::WatchOS] =
Targets[Darwin::TvOS] = "";
+ } else {
+ // Don't allow conflicts in any other platform.
+ int FirstTarget = llvm::array_lengthof(Targets);
+ for (int I = 0; I != llvm::array_lengthof(Targets); ++I) {
+ if (Targets[I].empty())
+ continue;
+ if (FirstTarget == llvm::array_lengthof(Targets))
+ FirstTarget = I;
+ else
+ TheDriver.Diag(diag::err_drv_conflicting_deployment_targets)
+ << Targets[FirstTarget] << Targets[I];
+ }
}
for (const auto &Target : llvm::enumerate(llvm::makeArrayRef(Targets))) {
More information about the cfe-commits
mailing list