[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
Fri Dec 2 10:57:58 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG9f07256a5192: [Driver] -p: change from unused warning to error for most targets (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D138255?vs=476319&id=479683#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138255/new/

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
@@ -6214,6 +6214,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
@@ -184,6 +184,9 @@
 - To match GCC, ``__ppc64__`` is no longer defined on PowerPC64 targets. Use
   ``__powerpc64__`` instead.
 
+- ``-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.479683.patch
Type: text/x-patch
Size: 1858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221202/8d09e406/attachment-0001.bin>


More information about the cfe-commits mailing list