Skip to content

Commit 7ef1718

Browse files
committed
[Driver] Don't try to spell check unsupported options
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`. Differential Revision: https://reviews.llvm.org/D156925
1 parent 61af957 commit 7ef1718

File tree

4 files changed

+6
-17
lines changed

4 files changed

+6
-17
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4773,7 +4773,6 @@ def _warn__EQ : Joined<["--"], "warn-=">, Alias<W_Joined>;
47734773
def _warn_ : Joined<["--"], "warn-">, Alias<W_Joined>;
47744774
def _write_dependencies : Flag<["--"], "write-dependencies">, Alias<MD>;
47754775
def _write_user_dependencies : Flag<["--"], "write-user-dependencies">, Alias<MMD>;
4776-
def _ : Joined<["--"], "">, Flags<[Unsupported]>;
47774776

47784777
// Hexagon feature flags.
47794778
let Flags = [TargetSpecific] in {

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,9 @@ InputArgList Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings,
286286
// Check for unsupported options.
287287
for (const Arg *A : Args) {
288288
if (A->getOption().hasFlag(options::Unsupported)) {
289-
unsigned DiagID;
290-
auto ArgString = A->getAsString(Args);
291-
std::string Nearest;
292-
if (getOpts().findNearest(
293-
ArgString, Nearest, IncludedFlagsBitmask,
294-
ExcludedFlagsBitmask | options::Unsupported) > 1) {
295-
DiagID = diag::err_drv_unsupported_opt;
296-
Diag(DiagID) << ArgString;
297-
} else {
298-
DiagID = diag::err_drv_unsupported_opt_with_suggestion;
299-
Diag(DiagID) << ArgString << Nearest;
300-
}
301-
ContainsError |= Diags.getDiagnosticLevel(DiagID, SourceLocation()) >
289+
Diag(diag::err_drv_unsupported_opt) << A->getAsString(Args);
290+
ContainsError |= Diags.getDiagnosticLevel(diag::err_drv_unsupported_opt,
291+
SourceLocation()) >
302292
DiagnosticsEngine::Warning;
303293
continue;
304294
}

clang/test/Driver/unsupported-option.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// RUN: not %clang %s --hedonism -### 2>&1 | \
22
// RUN: FileCheck %s
3-
// CHECK: error: unsupported option '--hedonism'
3+
// CHECK: error: unknown argument: '--hedonism'
44

55
// RUN: not %clang %s --hell -### 2>&1 | \
66
// RUN: FileCheck %s --check-prefix=DID-YOU-MEAN
7-
// DID-YOU-MEAN: error: unsupported option '--hell'; did you mean '--help'?
7+
// DID-YOU-MEAN: error: unknown argument '--hell'; did you mean '--help'?
88

99
// RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
1010
// RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR

flang/test/Driver/driver-version.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
! VERSION-NEXT: Thread model:
1010
! VERSION-NEXT: InstalledDir:
1111

12-
! ERROR: flang-new: error: unsupported option '--versions'; did you mean '--version'?
12+
! ERROR: flang-new: error: unknown argument '--versions'; did you mean '--version'?
1313

1414
! VERSION-FC1: LLVM version
1515

0 commit comments

Comments
 (0)