[PATCH] D156925: [Driver] Don't try to spell check unsupported options
Justin Bogner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 2 11:13:21 PDT 2023
bogner created this revision.
bogner added reviewers: Bigcheese, MaskRay.
Herald added a subscriber: mcrosier.
Herald added a reviewer: sscalpone.
Herald added a reviewer: awarzynski.
Herald added projects: Flang, All.
bogner requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, jdoerfert.
Herald added a project: clang.
We currently spell check options that are listed as unsupported, but
this doesn't make much sense. If an option is explicitly unsupported
why would one that's spelled similarly be useful?
It looks like the reason this was added was that we explicitly mark
all `--something` flags as Unsupported rather than just leaving them
undefined and treating them as unknown. Drop that handling so that we
don't regress on things like misspelling `--help`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156925
Files:
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/unsupported-option.c
flang/test/Driver/driver-version.f90
Index: flang/test/Driver/driver-version.f90
===================================================================
--- flang/test/Driver/driver-version.f90
+++ flang/test/Driver/driver-version.f90
@@ -9,7 +9,7 @@
! VERSION-NEXT: Thread model:
! VERSION-NEXT: InstalledDir:
-! ERROR: flang-new: error: unsupported option '--versions'; did you mean '--version'?
+! ERROR: flang-new: error: unknown argument '--versions'; did you mean '--version'?
! VERSION-FC1: LLVM version
Index: clang/test/Driver/unsupported-option.c
===================================================================
--- clang/test/Driver/unsupported-option.c
+++ clang/test/Driver/unsupported-option.c
@@ -1,10 +1,10 @@
// RUN: not %clang %s --hedonism -### 2>&1 | \
// RUN: FileCheck %s
-// CHECK: error: unsupported option '--hedonism'
+// CHECK: error: unknown argument: '--hedonism'
// RUN: not %clang %s --hell -### 2>&1 | \
// RUN: FileCheck %s --check-prefix=DID-YOU-MEAN
-// DID-YOU-MEAN: error: unsupported option '--hell'; did you mean '--help'?
+// DID-YOU-MEAN: error: unknown argument '--hell'; did you mean '--help'?
// RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
// RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -286,19 +286,9 @@
// Check for unsupported options.
for (const Arg *A : Args) {
if (A->getOption().hasFlag(options::Unsupported)) {
- unsigned DiagID;
- auto ArgString = A->getAsString(Args);
- std::string Nearest;
- if (getOpts().findNearest(
- ArgString, Nearest, IncludedFlagsBitmask,
- ExcludedFlagsBitmask | options::Unsupported) > 1) {
- DiagID = diag::err_drv_unsupported_opt;
- Diag(DiagID) << ArgString;
- } else {
- DiagID = diag::err_drv_unsupported_opt_with_suggestion;
- Diag(DiagID) << ArgString << Nearest;
- }
- ContainsError |= Diags.getDiagnosticLevel(DiagID, SourceLocation()) >
+ Diag(diag::err_drv_unsupported_opt) << A->getAsString(Args);
+ ContainsError |= Diags.getDiagnosticLevel(diag::err_drv_unsupported_opt,
+ SourceLocation()) >
DiagnosticsEngine::Warning;
continue;
}
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4773,7 +4773,6 @@
def _warn_ : Joined<["--"], "warn-">, Alias<W_Joined>;
def _write_dependencies : Flag<["--"], "write-dependencies">, Alias<MD>;
def _write_user_dependencies : Flag<["--"], "write-user-dependencies">, Alias<MMD>;
-def _ : Joined<["--"], "">, Flags<[Unsupported]>;
// Hexagon feature flags.
let Flags = [TargetSpecific] in {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156925.546552.patch
Type: text/x-patch
Size: 2956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230802/01be8c3e/attachment.bin>
More information about the cfe-commits
mailing list