[PATCH] D122344: [clang][driver] Disable non-functional --version option for clang -cc1

Emil Kieri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 23 12:43:28 PDT 2022


ekieri created this revision.
ekieri added reviewers: bruno, v.g.vassilev, thakis, dexonsmith.
Herald added a reviewer: sscalpone.
Herald added a project: All.
ekieri requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch removes --version as a clang -cc1 option.

  clang --version

and

  clang --cc1 -version

remain valid. This behaviour is consistent with clang -cc1as.

Previously, clang -cc1 accepted both --version and -version, but
only -version was acted upon. The call

  clang -cc1 --version

stalled without any message: --version was an accepted option but
triggered no action, and the driver waited for standard input.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122344

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Frontend/unknown-arg.c


Index: clang/test/Frontend/unknown-arg.c
===================================================================
--- clang/test/Frontend/unknown-arg.c
+++ clang/test/Frontend/unknown-arg.c
@@ -4,6 +4,9 @@
 // RUN: FileCheck %s --check-prefix=DID-YOU-MEAN
 // RUN: not %clang %s -E -Xclang --hel[ 2>&1 | \
 // RUN: FileCheck %s --check-prefix=DID-YOU-MEAN
+// RUN: not %clang_cc1 --version 2>&1 | \
+// RUN: FileCheck %s --check-prefix=DID-YOU-MEAN-VER
 
 // CHECK: error: unknown argument: '--helium'
 // DID-YOU-MEAN: error: unknown argument '--hel['; did you mean '--help'?
+// DID-YOU-MEAN-VER: error: unknown argument '--version'; did you mean '-version'?
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4200,7 +4200,7 @@
   HelpText<"Serialize compiler diagnostics to a file">;
 // We give --version different semantics from -version.
 def _version : Flag<["--"], "version">,
-  Flags<[CoreOption, CC1Option, FC1Option, FlangOption]>,
+  Flags<[CoreOption, FC1Option, FlangOption]>,
   HelpText<"Print version information">;
 def _signed_char : Flag<["--"], "signed-char">, Alias<fsigned_char>;
 def _std : Separate<["--"], "std">, Alias<std_EQ>;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122344.417719.patch
Type: text/x-patch
Size: 1301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220323/e9731f77/attachment.bin>


More information about the cfe-commits mailing list