diff options
Diffstat (limited to 'llvm/lib/Option/OptTable.cpp')
-rw-r--r-- | llvm/lib/Option/OptTable.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp index f3b438e829d..071c9db8720 100644 --- a/llvm/lib/Option/OptTable.cpp +++ b/llvm/lib/Option/OptTable.cpp @@ -444,15 +444,14 @@ static const char *getOptionHelpGroup(const OptTable &Opts, OptSpecifier Id) { } void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title, - bool ShowHidden) const { + bool ShowHidden, bool ShowAllAliases) const { PrintHelp(OS, Name, Title, /*Include*/ 0, /*Exclude*/ - (ShowHidden ? 0 : HelpHidden)); + (ShowHidden ? 0 : HelpHidden), ShowAllAliases); } - void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title, - unsigned FlagsToInclude, - unsigned FlagsToExclude) const { + unsigned FlagsToInclude, unsigned FlagsToExclude, + bool ShowAllAliases) const { OS << "OVERVIEW: " << Title << "\n"; OS << '\n'; OS << "USAGE: " << Name << " [options] <inputs>\n"; @@ -476,10 +475,19 @@ void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title, if (Flags & FlagsToExclude) continue; - if (const char *Text = getOptionHelpText(Id)) { + // If an alias doesn't have a help text, show a help text for the aliased + // option instead. + const char *HelpText = getOptionHelpText(Id); + if (!HelpText && ShowAllAliases) { + const Option Alias = getOption(Id).getAlias(); + if (Alias.isValid()) + HelpText = getOptionHelpText(Alias.getID()); + } + + if (HelpText) { const char *HelpGroup = getOptionHelpGroup(*this, Id); const std::string &OptName = getOptionHelpName(*this, Id); - GroupedOptionHelp[HelpGroup].push_back({OptName, Text}); + GroupedOptionHelp[HelpGroup].push_back({OptName, HelpText}); } } |