mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[llvm] [CommandLine] Do not suggest really hidden opts in nearest lookup
Skip 'really hidden' options when performing lookup of the nearest option when invalid option was passed. Since these options aren't even documented in --help-hidden, it seems inconsistent to suggest them to users. This fixes clang-tools-extra test failures due to unexpected suggestions when linking the tools to LLVM dylib (that provides more options than the subset of LLVM libraries linked directly). Differential Revision: https://reviews.llvm.org/D82001
This commit is contained in:
parent
b04677bc50
commit
6b982af8c2
@ -592,6 +592,10 @@ static Option *LookupNearestOption(StringRef Arg,
|
||||
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<StringRef, 16> OptionNames;
|
||||
O->getExtraOptionNames(OptionNames);
|
||||
if (O->hasArgStr())
|
||||
|
@ -1735,6 +1735,29 @@ TEST(CommandLineTest, OptionErrorMessageSuggest) {
|
||||
cl::ResetAllOptionOccurrences();
|
||||
}
|
||||
|
||||
TEST(CommandLineTest, OptionErrorMessageSuggestNoHidden) {
|
||||
// We expect that 'really hidden' option do not show up in option
|
||||
// suggestions.
|
||||
cl::ResetCommandLineParser();
|
||||
|
||||
StackOption<bool> OptLong("aluminium", cl::desc("Some long option"));
|
||||
StackOption<bool> 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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user