[PATCH] D41425: [darwin][driver] Warn about mismatching -<os>-version-min rather than superfluous -<os>-version-min compiler option
Alex Lorenz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 19 18:32:26 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321145: [darwin][driver] Warn about mismatching -<os>-version-min rather than (authored by arphaman, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D41425?vs=127637&id=127648#toc
Repository:
rL LLVM
https://reviews.llvm.org/D41425
Files:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-version.c
Index: cfe/trunk/test/Driver/darwin-version.c
===================================================================
--- cfe/trunk/test/Driver/darwin-version.c
+++ cfe/trunk/test/Driver/darwin-version.c
@@ -197,11 +197,25 @@
// 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 arm64-apple-ios10.1.0 -miphoneos-version-min=10.1.0.1 -c %s -### 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-TNO-OSV4 %s
+// CHECK-VERSION-TNO-OSV4: overriding '-miphoneos-version-min=10.1.0.1' option with '--target=arm64-apple-ios10.1.0'
+
+// 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: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
@@ -1523,12 +1523,29 @@
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;
+ bool TargetExtra;
+ unsigned ArgMajor, ArgMinor, ArgMicro;
+ bool ArgExtra;
+ if (OSTarget->getPlatform() != OSVersionArgTarget->getPlatform() ||
+ (Driver::GetReleaseVersion(OSTarget->getOSVersion(), TargetMajor,
+ TargetMinor, TargetMicro, TargetExtra) &&
+ Driver::GetReleaseVersion(OSVersionArgTarget->getOSVersion(),
+ ArgMajor, ArgMinor, ArgMicro, ArgExtra) &&
+ (VersionTuple(TargetMajor, TargetMinor, TargetMicro) !=
+ VersionTuple(ArgMajor, ArgMinor, ArgMicro) ||
+ TargetExtra != ArgExtra))) {
+ // 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: D41425.127648.patch
Type: text/x-patch
Size: 3903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171220/ba54ec4f/attachment-0001.bin>
More information about the cfe-commits
mailing list