Skip to content

Commit

Permalink
[clang][driver] Disable non-functional --version option for clang -cc1
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ekieri committed Mar 25, 2022
1 parent b97f260 commit 35b89bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/include/clang/Driver/Options.td
Expand Up @@ -4203,7 +4203,7 @@ def _serialize_diags : Separate<["-", "--"], "serialize-diagnostics">, Flags<[No
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>;
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Frontend/unknown-arg.c
Expand Up @@ -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'?

0 comments on commit 35b89bc

Please sign in to comment.