[PATCH] D138255: [Driver] -p: change from unused warning to error for most targets
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 17 19:42:22 PST 2022
MaskRay created this revision.
MaskRay added reviewers: francii, hubert.reinterpretcast, cebowleratibm, thesamesam, brad.
Herald added subscribers: StephenFan, krytarowski, arichardson, emaste.
Herald added a reviewer: ctetreau.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
AIX and OpenBSD seem to use -p. For most targets (at least FreeBSD and Linux),
-p is legacy (GCC freebsd has a warning). We don't want the uses to grow, so
making -p an alias for -pg is not recommended. I think the uses are small.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138255
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/p.c
Index: clang/test/Driver/p.c
===================================================================
--- /dev/null
+++ clang/test/Driver/p.c
@@ -0,0 +1,7 @@
+/// For most targets -p is legacy. We used to report -Wunused-command-line-argument.
+// RUN: %clang -### --target=x86_64-unknown-linux-gnu -c -p %s 2>&1 | FileCheck %s --check-prefix=ERR
+
+// RUN: %clang -### --target=x86_64-unknown-openbsd -c -p %s 2>&1 | FileCheck %s --implicit-check-not=error:
+// RUN: %clang -### --target=powerpc64-ibm-aix -c -p %s 2>&1 | FileCheck %s --implicit-check-not=error:
+
+// ERR: error: unsupported option '-p' for target {{.*}}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6304,6 +6304,12 @@
<< A->getAsString(Args) << TripleStr;
}
}
+ if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+ if (!TC.getTriple().isOSAIX() && !TC.getTriple().isOSOpenBSD()) {
+ D.Diag(diag::err_drv_unsupported_opt_for_target)
+ << A->getAsString(Args) << TripleStr;
+ }
+ }
if (Args.getLastArg(options::OPT_fapple_kext) ||
(Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -181,6 +181,9 @@
``$prefix/lib/clang/$CLANG_MAJOR_VERSION`` and can be queried using
``clang -print-resource-dir``, just like before.
+- ``-p`` is rejected for all targets which are not AIX or OpenBSD. ``-p`` led
+ to an ``-Wunused-command-line-argument`` warning in previous releases.
+
What's New in Clang |release|?
==============================
Some of the major new features and improvements to Clang are listed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138255.476319.patch
Type: text/x-patch
Size: 1873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221118/92b4e556/attachment-0001.bin>
More information about the cfe-commits
mailing list