Index: llvm/lib/Support/CommandLine.cpp =================================================================== --- llvm/lib/Support/CommandLine.cpp +++ llvm/lib/Support/CommandLine.cpp @@ -592,6 +592,10 @@ ie = OptionsMap.end(); it != ie; ++it) { Option *O = it->second; + // Do not suggest really hidden options (not shown in any help). + if (O->getOptionHiddenFlag() == ReallyHidden) + continue; + SmallVector OptionNames; O->getExtraOptionNames(OptionNames); if (O->hasArgStr()) Index: llvm/unittests/Support/CommandLineTest.cpp =================================================================== --- llvm/unittests/Support/CommandLineTest.cpp +++ llvm/unittests/Support/CommandLineTest.cpp @@ -1735,6 +1735,29 @@ cl::ResetAllOptionOccurrences(); } +TEST(CommandLineTest, OptionErrorMessageSuggestNoHidden) { + // We expect that 'really hidden' option do not show up in option + // suggestions. + cl::ResetCommandLineParser(); + + StackOption OptLong("aluminium", cl::desc("Some long option")); + StackOption OptLong2("aluminum", cl::desc("Bad option"), + cl::ReallyHidden); + + const char *args[] = {"prog", "--alumnum"}; + + std::string Errs; + raw_string_ostream OS(Errs); + + EXPECT_FALSE(cl::ParseCommandLineOptions(2, args, StringRef(), &OS)); + OS.flush(); + EXPECT_FALSE(Errs.find("prog: Did you mean '--aluminium'?\n") == + std::string::npos); + Errs.clear(); + + cl::ResetAllOptionOccurrences(); +} + TEST(CommandLineTest, Callback) { cl::ResetCommandLineParser();