[clang] 35b89bc - [clang][driver] Disable non-functional --version option for clang -cc1
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; def _std : Separate<["--"], "std">, Alias; 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'? ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 577827c - [flang][driver] Make --version and -version consistent with clang
Author: Emil Kieri Date: 2022-03-28T22:53:17+02:00 New Revision: 577827cbbf1033612d6ce15169f33ee5709abbfc URL: https://github.com/llvm/llvm-project/commit/577827cbbf1033612d6ce15169f33ee5709abbfc DIFF: https://github.com/llvm/llvm-project/commit/577827cbbf1033612d6ce15169f33ee5709abbfc.diff LOG: [flang][driver] Make --version and -version consistent with clang This patch makes -version valid, and --version invalid, for flang-new -fc1. The invocation flang-new --version remains valid. This behaviour is consistent with clang (and with clang -cc1 and clang -cc1as). Previously, flang-new -fc1 accepted --version (as per Options.td), but the frontend driver acutally checks for -version. As a result, flang-new -fc1 --version triggered no action, emitted no message, and stalled waiting for standard input. Fixes #51438 Reviewed By: PeteSteinfeld, awarzynski Differential Revision: https://reviews.llvm.org/D122542 Added: Modified: clang/include/clang/Driver/Options.td flang/test/Driver/driver-help.f90 flang/test/Driver/driver-version.f90 Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index ac2f479f159eb..8c488f254b1ec 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4205,7 +4205,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, FC1Option, FlangOption]>, + Flags<[CoreOption, FlangOption]>, HelpText<"Print version information">; def _signed_char : Flag<["--"], "signed-char">, Alias; def _std : Separate<["--"], "std">, Alias; @@ -5749,11 +5749,16 @@ def aligned_alloc_unavailable : Flag<["-"], "faligned-alloc-unavailable">, // Language Options //===--===// -let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { +let Flags = [CC1Option, CC1AsOption, FC1Option, NoDriverOption] in { def version : Flag<["-"], "version">, HelpText<"Print the compiler version">, MarshallingInfoFlag>; + +} // let Flags = [CC1Option, CC1AsOption, FC1Option, NoDriverOption] + +let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { + def main_file_name : Separate<["-"], "main-file-name">, HelpText<"Main file name to use for debug info and source if missing">, MarshallingInfoString>; diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90 index 16cc6c428082b..e020fa3801fd9 100644 --- a/flang/test/Driver/driver-help.f90 +++ b/flang/test/Driver/driver-help.f90 @@ -135,7 +135,7 @@ ! HELP-FC1-NEXT: -test-io Run the InputOuputTest action. Use for development and testing only. ! HELP-FC1-NEXT: -triple Specify target triple (e.g. i686-apple-darwin9) ! HELP-FC1-NEXT: -U Undefine macro -! HELP-FC1-NEXT: --version Print version information +! HELP-FC1-NEXT: -version Print the compiler version ! HELP-FC1-NEXT: -WEnable the specified warning !--- diff --git a/flang/test/Driver/driver-version.f90 b/flang/test/Driver/driver-version.f90 index c3569be12a1a0..e38a1e58b60bd 100644 --- a/flang/test/Driver/driver-version.f90 +++ b/flang/test/Driver/driver-version.f90 @@ -2,15 +2,21 @@ !--- ! RUN LINES !--- -! RUN: %flang --version 2>&1 | FileCheck %s +! RUN: %flang --version 2>&1 | FileCheck %s --check-prefix=VERSION ! RUN: not %flang --versions 2>&1 | FileCheck %s --check-prefix=ERROR +! RUN: %flang_fc1 -version 2>&1 | FileCheck %s --check-prefix=VERSION-FC1 +! RUN: not %flang_fc1 --version 2>&1 | FileCheck %s --check-prefix=ERROR-FC1 !--- ! EXPECTED OUTPUT !--- -! CHECK: flang-new version -! CHECK-NEXT: Target: -! CHECK-NEXT: Thread model: -! CHECK-NEXT: InstalledDir: +! VERSION: flang-new version +! VERSION-NEXT: Target: +! VERSION-NEXT: Thread model: +! VERSION-NEXT: InstalledDir: ! ERROR: flang-new: error: unsupported option '--versions'; did you mean '--version'? + +! VERSION-FC1: LLVM version + +! ERROR-FC1: error: unknown argument '--version'; did you mean '-version'? ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] da1fc3a - [Driver][NFC] Simplify handling of flags in Options.td
Author: Emil Kieri Date: 2022-04-07T20:38:51+02:00 New Revision: da1fc3ae955da47dc43d8d2e8f4d5a52deac7cf9 URL: https://github.com/llvm/llvm-project/commit/da1fc3ae955da47dc43d8d2e8f4d5a52deac7cf9 DIFF: https://github.com/llvm/llvm-project/commit/da1fc3ae955da47dc43d8d2e8f4d5a52deac7cf9.diff LOG: [Driver][NFC] Simplify handling of flags in Options.td We aim at improving the readability and maintainability of Options.td, and in particular its handling of 'Flags', by - limiting the extent of 'let Flags = [...] in {'s, and - adding closing comments to matching '}'s. - being more consistent about empty lines around 'let Flags' and '}'. More concretely, - we do not let a 'let Flags' span across several headline comments. When all 'def's in two consecutive headlines share the same flags, we stil close and start a new 'let Flags' at the intermediate headline. - when a 'let Flags' span just one or two 'def's, set 'Flags' within the 'def's instead. - we remove nested 'let Flags'. Note that nested 'let Flags' can be quite confusing, especially when the outer was started long before the inner. Moving a 'def' out of the inner 'let Flags' and setting 'Flags' within the 'def' will not have the intended effect, as those flags will be overridden by the outer 'let Flags'. Reviewed By: awarzynski, jansvoboda11, hans Differential Revision: https://reviews.llvm.org/D123070 Added: Modified: clang/include/clang/Driver/Options.td Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 0f7cfa7eb883f..2e4b9f347ba5f 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4690,15 +4690,16 @@ def fno_sycl : Flag<["-"], "fno-sycl">, Flags<[NoXarchOption, CoreOption]>, //===--===// // FLangOption + CoreOption + NoXarchOption //===--===// -let Flags = [FlangOption, FlangOnlyOption, NoXarchOption, CoreOption] in { + def Xflang : Separate<["-"], "Xflang">, HelpText<"Pass to the flang compiler">, MetaVarName<"">, - Flags<[NoXarchOption, CoreOption]>, Group; -} + Flags<[FlangOption, FlangOnlyOption, NoXarchOption, CoreOption]>, + Group; //===--===// // FlangOption and FC1 Options //===--===// + let Flags = [FC1Option, FlangOption, FlangOnlyOption] in { def cpp : Flag<["-"], "cpp">, Group, @@ -4745,7 +4746,8 @@ defm implicit_none : OptInFC1FFlag<"implicit-none", "No implicit typing allowed def fno_automatic : Flag<["-"], "fno-automatic">, Group, HelpText<"Implies the SAVE attribute for non-automatic local objects in subprograms unless RECURSIVE">; -} + +} // let Flags = [FC1Option, FlangOption, FlangOnlyOption] def J : JoinedOrSeparate<["-"], "J">, Flags<[RenderJoined, FlangOption, FC1Option, FlangOnlyOption]>, @@ -4755,6 +4757,7 @@ def J : JoinedOrSeparate<["-"], "J">, //===--===// // FC1 Options //===--===// + let Flags = [FC1Option, FlangOnlyOption] in { def fget_definition : MultiArg<["-"], "fget-definition", 3>, @@ -4809,13 +4812,7 @@ def emit_mlir : Flag<["-"], "emit-mlir">, Group, HelpText<"Build the parse tree, then lower it to MLIR">; def emit_fir : Flag<["-"], "emit-fir">, Alias; -} - -//===--===// -// CC1 Options -//===--===// - -let Flags = [CC1Option, NoDriverOption] in { +} // let Flags = [FC1Option, FlangOnlyOption] //===--===// // Target Options (cc1 + cc1as) @@ -4850,6 +4847,7 @@ def darwin_target_variant_sdk_version_EQ : Joined<["-"], //===--===// // Target Options (cc1 + cc1as + fc1) //===--===// + let Flags = [CC1Option, CC1AsOption, FC1Option, NoDriverOption] in { def triple : Separate<["-"], "triple">, @@ -4863,6 +4861,8 @@ def triple : Separate<["-"], "triple">, // Target Options (other) //===--===// +let Flags = [CC1Option, NoDriverOption] in { + def target_linker_version : Separate<["-"], "target-linker-version">, HelpText<"Target linker version">, MarshallingInfoString>; @@ -4877,10 +4877,14 @@ defm padding_on_unsigned_fixed_point : BoolOption<"f", "padding-on-unsigned-fixe NegFlag>, ShouldParseIf; +} // le