diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -19,7 +19,7 @@ def err_drv_unsupported_opt_for_language_mode : Error< "unsupported option '%0' for language mode '%1'">; def err_drv_unsupported_option_argument : Error< - "unsupported argument '%1' to option '-%0'">; + "unsupported argument '%1' to option '%0'">; def err_drv_unknown_stdin_type : Error< "-E or -x required when input is from standard input">; def err_drv_unknown_stdin_type_clang_cl : Error< diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -703,7 +703,7 @@ if (LTOMode == LTOK_Unknown) { D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << A->getValue(); + << A->getSpelling() << A->getValue(); return LTOK_None; } return LTOMode; @@ -735,7 +735,7 @@ if (RT == OMPRT_Unknown) { if (A) Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << A->getValue(); + << A->getSpelling() << A->getValue(); else // FIXME: We could use a nicer diagnostic here. Diag(diag::err_drv_unsupported_opt) << "-fopenmp"; diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -249,7 +249,7 @@ SanitizerSet S; S.Mask = InvalidValues; D.Diag(diag::err_drv_unsupported_option_argument) - << Arg->getOption().getName() << toString(S); + << Arg->getSpelling() << toString(S); } TrappingKinds |= expandSanitizerGroups(Add) & ~TrapRemove; } else if (Arg->getOption().matches(options::OPT_fno_sanitize_trap_EQ)) { @@ -604,7 +604,7 @@ SetToDiagnose.Mask |= KindsToDiagnose; if (DiagnoseErrors) D.Diag(diag::err_drv_unsupported_option_argument) - << Arg->getOption().getName() << toString(SetToDiagnose); + << Arg->getSpelling() << toString(SetToDiagnose); DiagnosedUnrecoverableKinds |= KindsToDiagnose; } RecoverableKinds |= expandSanitizerGroups(Add); @@ -619,7 +619,7 @@ SetToDiagnose.Mask |= KindsToDiagnose; if (DiagnoseErrors) D.Diag(diag::err_drv_unsupported_option_argument) - << Arg->getOption().getName() << toString(SetToDiagnose); + << Arg->getSpelling() << toString(SetToDiagnose); DiagnosedAlwaysRecoverableKinds |= KindsToDiagnose; } RecoverableKinds &= ~expandSanitizerGroups(Remove); @@ -951,7 +951,7 @@ auto parsedAsanDtorKind = AsanDtorKindFromString(Arg->getValue()); if (parsedAsanDtorKind == llvm::AsanDtorKind::Invalid && DiagnoseErrors) { TC.getDriver().Diag(clang::diag::err_drv_unsupported_option_argument) - << Arg->getOption().getName() << Arg->getValue(); + << Arg->getSpelling() << Arg->getValue(); } AsanDtorKind = parsedAsanDtorKind; } @@ -964,7 +964,7 @@ llvm::AsanDetectStackUseAfterReturnMode::Invalid && DiagnoseErrors) { TC.getDriver().Diag(clang::diag::err_drv_unsupported_option_argument) - << Arg->getOption().getName() << Arg->getValue(); + << Arg->getSpelling() << Arg->getValue(); } AsanUseAfterReturn = parsedAsanUseAfterReturn; } @@ -1346,7 +1346,7 @@ Kinds |= Kind; else if (DiagnoseErrors) D.Diag(clang::diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Value; + << A->getSpelling() << Value; } return Kinds; } @@ -1381,7 +1381,7 @@ .Default(0); if (F == 0 && DiagnoseErrors) D.Diag(clang::diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Value; + << A->getSpelling() << Value; Features |= F; } return Features; @@ -1403,7 +1403,7 @@ .Default(0); if (F == 0 && DiagnoseErrors) D.Diag(clang::diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Value; + << A->getSpelling() << Value; Features |= F; } return Features; diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp --- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -274,9 +274,9 @@ // If "-Wa,-march=" is used, 'WaMArch' will contain the argument's value, // while 'A' is uninitialized. Only dereference 'A' in the other case. if (!WaMArch.empty()) - Diag << "march=" << WaMArch; + Diag << "-march=" << WaMArch; else - Diag << A->getOption().getName() << A->getValue(); + Diag << A->getSpelling() << A->getValue(); } if (Args.getLastArg(options::OPT_mgeneral_regs_only)) { @@ -330,7 +330,7 @@ continue; } D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Scope; + << A->getSpelling() << Scope; break; } } diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -122,7 +122,7 @@ (Split.second.size() && !DecodeARMFeatures(D, Split.second, CPUName, ArchKind, Features, ArgFPUID))) D.Diag(clang::diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << A->getValue(); + << A->getSpelling() << A->getValue(); } // Check -mcpu=. Needs ArchName to handle -mcpu=generic. @@ -139,7 +139,7 @@ (Split.second.size() && !DecodeARMFeatures(D, Split.second, CPU, ArchKind, Features, ArgFPUID))) D.Diag(clang::diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << A->getValue(); + << A->getSpelling() << A->getValue(); } bool arm::useAAPCSForMachO(const llvm::Triple &T) { @@ -879,7 +879,7 @@ continue; } D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Scope; + << A->getSpelling() << Scope; break; } } diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp b/clang/lib/Driver/ToolChains/Arch/Mips.cpp --- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp +++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp @@ -306,7 +306,7 @@ } } else D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; } if (Arg *A = Args.getLastArg(options::OPT_mabs_EQ)) { @@ -327,7 +327,7 @@ } } else { D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; } } diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -73,7 +73,7 @@ CPU = llvm::sys::getHostCPUName(); if (!getRISCFeaturesFromMcpu(Triple, CPU, Features)) D.Diag(clang::diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << CPU; + << A->getSpelling() << CPU; } // Handle features corresponding to "-ffixed-X" options diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -255,7 +255,7 @@ Features.push_back("+harden-sls-ijmp"); } else if (Scope != "none") { D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Scope; + << A->getSpelling() << Scope; } } } diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -958,7 +958,7 @@ CmdArgs.push_back("-fprofile-update=atomic"); else if (Val != "single") D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; } else if (SanArgs.needsTsanRt()) { CmdArgs.push_back("-fprofile-update=atomic"); } @@ -1141,7 +1141,7 @@ } } else { D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Value; + << A->getSpelling() << Value; } } } @@ -1673,7 +1673,7 @@ Scope = A->getValue(); if (Scope != "none" && Scope != "non-leaf" && Scope != "all") D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Scope; + << A->getSpelling() << Scope; Key = "a_key"; IndirectBranches = false; } else { @@ -1681,7 +1681,7 @@ llvm::ARM::ParsedBranchProtection PBP; if (!llvm::ARM::parseBranchProtection(A->getValue(), PBP, DiagMsg)) D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << DiagMsg; + << A->getSpelling() << DiagMsg; if (!isAArch64 && PBP.Key == "b_key") D.Diag(diag::warn_unsupported_branch_protection) << "b-key" << A->getAsString(Args); @@ -1902,7 +1902,7 @@ } else if (!Val.equals("scalable")) // Handle the unsupported values passed to msve-vector-bits. D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; } AddAAPCSVolatileBitfieldArgs(Args, CmdArgs); @@ -2059,7 +2059,7 @@ CmdArgs.push_back(Args.MakeArgString("-mips-compact-branches=" + Val)); } else D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; } else D.Diag(diag::warn_target_unsupported_compact_branches) << CPUName; } @@ -2294,7 +2294,7 @@ CmdArgs.push_back(Args.MakeArgString("-inline-asm=" + Value)); } else { D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Value; + << A->getSpelling() << Value; } } else if (D.IsCLMode()) { CmdArgs.push_back("-mllvm"); @@ -2377,7 +2377,7 @@ if (Mregparm != 4) { getToolChain().getDriver().Diag( diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Value; + << A->getSpelling() << Value; } } } @@ -2558,7 +2558,7 @@ ImplicitIt = A->getValue(); if (!CheckARMImplicitITArg(ImplicitIt)) D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << ImplicitIt; + << A->getSpelling() << ImplicitIt; continue; default: break; @@ -2721,7 +2721,7 @@ D.PrintVersion(C, llvm::outs()); } else { D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Value; + << A->getSpelling() << Value; } } } @@ -2855,7 +2855,7 @@ TrappingMath = true; } else D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; break; } } @@ -2942,7 +2942,7 @@ LastSeenFfpContractOption = Val; } else D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; break; } @@ -2970,7 +2970,7 @@ TrappingMath = TrappingMathPresent = true; } else D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; break; } @@ -2982,7 +2982,7 @@ FPEvalMethod = Val; else D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; break; } @@ -3436,7 +3436,7 @@ TrivialAutoVarInit = Val; else D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; break; } } @@ -4094,7 +4094,7 @@ return DwarfFissionKind::Single; D.Diag(diag::err_drv_unsupported_option_argument) - << Arg->getOption().getName() << Arg->getValue(); + << Arg->getSpelling() << Arg->getValue(); return DwarfFissionKind::None; } @@ -7879,7 +7879,7 @@ CmdArgs.push_back(Args.MakeArgString("-x86-asm-syntax=" + Value)); } else { getToolChain().getDriver().Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Value; + << A->getSpelling() << Value; } } } diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -296,7 +296,7 @@ CmdArgs.push_back(Args.MakeArgString("--compress-debug-sections=" + V)); else TC.getDriver().Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << V; + << A->getSpelling() << V; } } diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -104,7 +104,7 @@ // Clang's "fast-honor-pragmas" option is not supported because it is // non-standard D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; } for (const Arg *A : Args) { diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -729,7 +729,7 @@ Args.MakeArgString("--compress-debug-sections=" + Twine(Value))); } else { D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Value; + << A->getSpelling() << Value; } } } diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp --- a/clang/lib/Driver/ToolChains/Hexagon.cpp +++ b/clang/lib/Driver/ToolChains/Hexagon.cpp @@ -40,7 +40,7 @@ StringRef Val = A->getValue(); if (!Val.equals_insensitive("64b") && !Val.equals_insensitive("128b")) D.Diag(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << Val; + << A->getSpelling() << Val; } } diff --git a/clang/lib/Driver/ToolChains/MSP430.cpp b/clang/lib/Driver/ToolChains/MSP430.cpp --- a/clang/lib/Driver/ToolChains/MSP430.cpp +++ b/clang/lib/Driver/ToolChains/MSP430.cpp @@ -101,7 +101,7 @@ Features.push_back("+hwmultf5"); } else { D.Diag(clang::diag::err_drv_unsupported_option_argument) - << HWMultArg->getOption().getName() << HWMult; + << HWMultArg->getSpelling() << HWMult; } } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1711,7 +1711,7 @@ StringRef Value = A->getValue(); if (Value != "simple" && Value != "mangled") Diags.Report(diag::err_drv_unsupported_option_argument) - << A->getOption().getName() << A->getValue(); + << A->getSpelling() << A->getValue(); Opts.setDebugSimpleTemplateNames( StringRef(A->getValue()) == "simple" ? codegenoptions::DebugTemplateNamesKind::Simple diff --git a/clang/test/Driver/mingw-cfguard.c b/clang/test/Driver/mingw-cfguard.c --- a/clang/test/Driver/mingw-cfguard.c +++ b/clang/test/Driver/mingw-cfguard.c @@ -25,4 +25,4 @@ // GUARD_NOCHECKS-NOT: "--no-guard-cf" // RUN: %clang --target=x86_64-w64-windows-gnu -### %s -mguard=xxx 2>&1 | FileCheck -check-prefix=GUARD_UNKNOWN %s -// GUARD_UNKNOWN: error: unsupported argument 'xxx' to option '--mguard=' +// GUARD_UNKNOWN: error: unsupported argument 'xxx' to option '-mguard=' diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -688,7 +688,7 @@ fpContractMode = LangOptions::FPM_Fast; else { diags.Report(clang::diag::err_drv_unsupported_option_argument) - << a->getOption().getName() << val; + << a->getSpelling() << val; return false; }