Index: cfe/trunk/test/Driver/unknown-arg.c =================================================================== --- cfe/trunk/test/Driver/unknown-arg.c +++ cfe/trunk/test/Driver/unknown-arg.c @@ -12,6 +12,8 @@ // RUN: FileCheck %s --check-prefix=CL-ERROR-DID-YOU-MEAN // RUN: %clang_cl -cake-is-lie -%0 -%d -HHHH -munknown-to-clang-option -print-stats -funknown-to-clang-option -c -Wno-unknown-argument -### -- %s 2>&1 | \ // RUN: FileCheck %s --check-prefix=SILENT +// RUN: not %clang -cc1as -hell --version -debug-info-macros 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CC1AS-DID-YOU-MEAN // CHECK: error: unknown argument: '-cake-is-lie' // CHECK: error: unknown argument: '-%0' @@ -41,6 +43,9 @@ // CL-ERROR-DID-YOU-MEAN: error: unknown argument ignored in clang-cl '-helo' (did you mean '-help'?) // SILENT-NOT: error: // SILENT-NOT: warning: +// CC1AS-DID-YOU-MEAN: error: unknown argument '-hell', did you mean '-help'? +// CC1AS-DID-YOU-MEAN: error: unknown argument '--version', did you mean '-version'? +// CC1AS-DID-YOU-MEAN: error: unknown argument '-debug-info-macros', did you mean '-debug-info-macro'? // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s Index: cfe/trunk/tools/driver/cc1as_main.cpp =================================================================== --- cfe/trunk/tools/driver/cc1as_main.cpp +++ cfe/trunk/tools/driver/cc1as_main.cpp @@ -181,7 +181,13 @@ // Issue errors on unknown arguments. for (const Arg *A : Args.filtered(OPT_UNKNOWN)) { - Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args); + auto ArgString = A->getAsString(Args); + std::string Nearest; + if (OptTbl->findNearest(ArgString, Nearest, IncludedFlagsBitmask) > 1) + Diags.Report(diag::err_drv_unknown_argument) << ArgString; + else + Diags.Report(diag::err_drv_unknown_argument_with_suggestion) + << ArgString << Nearest; Success = false; }