[clang] 35b89bc - [clang][driver] Disable non-functional --version option for clang -cc1

Emil Kieri via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 25 11:05:37 PDT 2022


Author: Emil Kieri
Date: 2022-03-25T19:04:27+01:00
New Revision: 35b89bc24ca58d5b3a87578f69936afb26ef3b69

URL: https://github.com/llvm/llvm-project/commit/35b89bc24ca58d5b3a87578f69936afb26ef3b69
DIFF: https://github.com/llvm/llvm-project/commit/35b89bc24ca58d5b3a87578f69936afb26ef3b69.diff

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

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.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D122344

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 784751a1a6863..488692e16145f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4203,7 +4203,7 @@ def _serialize_diags : Separate<["-", "--"], "serialize-diagnostics">, Flags<[No
   HelpText<"Serialize compiler diagnostics to a file">;
 // We give --version 
diff erent 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>;

diff  --git a/clang/test/Frontend/unknown-arg.c b/clang/test/Frontend/unknown-arg.c
index eb2fb1aee2dd5..74a6c842da908 100644
--- a/clang/test/Frontend/unknown-arg.c
+++ b/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'?


        


More information about the cfe-commits mailing list