[PATCH] D41424: [darwin][driver] Warn about mismatching -<os>-version-min rather than superfl
Alex Lorenz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 19 17:37:12 PST 2017
arphaman created this revision.
Herald added a subscriber: cfe-commits.
Repository:
rC Clang
https://reviews.llvm.org/D41424
Files:
lib/Driver/ToolChains/Darwin.cpp
test/Driver/darwin-version.c
Index: test/Driver/darwin-version.c
===================================================================
--- test/Driver/darwin-version.c
+++ test/Driver/darwin-version.c
@@ -197,11 +197,21 @@
// RUN: %clang -target x86_64-apple-macos10.11.2 -mmacos-version-min=10.6 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-TNO-OSV1 %s
-// CHECK-VERSION-TNO-OSV1: argument unused during compilation: '-mmacosx-version-min=10.6'
+// CHECK-VERSION-TNO-OSV1: overriding '-mmacosx-version-min=10.6' option with '--target=x86_64-apple-macos10.11.2'
// RUN: %clang -target x86_64-apple-macos -miphoneos-version-min=9.1 -c %s -### 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-TNO-OSV2 %s
-// CHECK-VERSION-TNO-OSV2: argument unused during compilation: '-miphoneos-version-min=9.1'
+// CHECK-VERSION-TNO-OSV2: overriding '-miphoneos-version-min=9.1' option with '--target=x86_64-apple-macos'
+
+// RUN: %clang -target x86_64-apple-ios -miphonesimulator-version-min=10.0 -c %s -### 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-TNO-OSV3 %s
+// CHECK-VERSION-TNO-OSV3: overriding '-mios-simulator-version-min=10.0' option with '--target=x86_64-apple-ios'
+// CHECK-VERSION-TNO-OSV3-NOT: argument unused during compilation
+
+// RUN: %clang -target x86_64-apple-macos10.6 -mmacos-version-min=10.6 -c %s -### 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-TNO-SAME %s
+// CHECK-VERSION-TNO-SAME-NOT: overriding
+// CHECK-VERSION-TNO-SAME-NOT: argument unused during compilation
// Target with OS version is not overriden by -m<os>-version-min variables:
Index: lib/Driver/ToolChains/Darwin.cpp
===================================================================
--- lib/Driver/ToolChains/Darwin.cpp
+++ lib/Driver/ToolChains/Darwin.cpp
@@ -1523,12 +1523,27 @@
Optional<DarwinPlatform> OSTarget =
getDeploymentTargetFromTargetArg(Args, getTriple(), getDriver());
if (OSTarget) {
- // Warn about superfluous -m<os>-version-min arg.
Optional<DarwinPlatform> OSVersionArgTarget =
getDeploymentTargetFromOSVersionArg(Args, getDriver());
- if (OSVersionArgTarget)
- getDriver().Diag(clang::diag::warn_drv_unused_argument)
- << OSVersionArgTarget->getAsString(Args, Opts);
+ if (OSVersionArgTarget) {
+ unsigned TargetMajor, TargetMinor, TargetMicro;
+ unsigned ArgMajor, ArgMinor, ArgMicro;
+ bool HadExtra;
+ if (OSTarget->getPlatform() != OSVersionArgTarget->getPlatform() ||
+ (Driver::GetReleaseVersion(OSTarget->getOSVersion(), TargetMajor,
+ TargetMinor, TargetMicro, HadExtra) &&
+ Driver::GetReleaseVersion(OSVersionArgTarget->getOSVersion(),
+ ArgMajor, ArgMinor, ArgMicro, HadExtra) &&
+ VersionTuple(TargetMajor, TargetMinor, TargetMicro) !=
+ VersionTuple(ArgMajor, ArgMinor, ArgMicro))) {
+ // Warn about -m<os>-version-min that doesn't match the OS version
+ // that's specified in the target.
+ std::string OSVersionArg = OSVersionArgTarget->getAsString(Args, Opts);
+ std::string TargetArg = OSTarget->getAsString(Args, Opts);
+ getDriver().Diag(clang::diag::warn_drv_overriding_flag_option)
+ << OSVersionArg << TargetArg;
+ }
+ }
} else {
// The OS target can be specified using the -m<os>version-min argument.
OSTarget = getDeploymentTargetFromOSVersionArg(Args, getDriver());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41424.127635.patch
Type: text/x-patch
Size: 3492 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171220/83ba9bb3/attachment.bin>
More information about the cfe-commits
mailing list