[llvm] [CommandLine] Better report unknown subcommands (PR #74811)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 13 00:24:51 PST 2023
================
@@ -1687,21 +1708,35 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
}
if (!Handler) {
- if (SinkOpts.empty()) {
- *Errs << ProgramName << ": Unknown command line argument '" << argv[i]
- << "'. Try: '" << argv[0] << " --help'\n";
-
- if (NearestHandler) {
- // If we know a near match, report it as well.
- *Errs << ProgramName << ": Did you mean '"
- << PrintArg(NearestHandlerString, 0) << "'?\n";
- }
-
- ErrorParsing = true;
- } else {
+ if (!SinkOpts.empty()) {
for (Option *SinkOpt : SinkOpts)
SinkOpt->addOccurrence(i, "", StringRef(argv[i]));
+ continue;
}
+
+ auto reportUnknownArgument = [&](bool IsArg,
----------------
jh7370 wrote:
Nit: I think the LLVM consensus is that lambdas are objects, not functions, so should be named with upper-case, i.e. `ReportUnknownArgument`.
https://github.com/llvm/llvm-project/pull/74811
More information about the llvm-commits
mailing list