[PATCH] D35476: [libOption] - Add flag allowing to print options aliases in help text.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 26 02:10:36 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309087: [libOption] - Add flag allowing to print options aliases in help text. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D35476?vs=108052&id=108229#toc
Repository:
rL LLVM
https://reviews.llvm.org/D35476
Files:
llvm/trunk/include/llvm/Option/OptTable.h
llvm/trunk/lib/Option/OptTable.cpp
Index: llvm/trunk/lib/Option/OptTable.cpp
===================================================================
--- llvm/trunk/lib/Option/OptTable.cpp
+++ llvm/trunk/lib/Option/OptTable.cpp
@@ -444,15 +444,14 @@
}
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 @@
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});
}
}
Index: llvm/trunk/include/llvm/Option/OptTable.h
===================================================================
--- llvm/trunk/include/llvm/Option/OptTable.h
+++ llvm/trunk/include/llvm/Option/OptTable.h
@@ -191,12 +191,16 @@
/// \param FlagsToInclude - If non-zero, only include options with any
/// of these flags set.
/// \param FlagsToExclude - Exclude options with any of these flags set.
- void PrintHelp(raw_ostream &OS, const char *Name,
- const char *Title, unsigned FlagsToInclude,
- unsigned FlagsToExclude) const;
+ /// \param ShowAllAliases - If true, display all options including aliases
+ /// that don't have help texts. By default, we display
+ /// only options that are not hidden and have help
+ /// texts.
+ void PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
+ unsigned FlagsToInclude, unsigned FlagsToExclude,
+ bool ShowAllAliases) const;
- void PrintHelp(raw_ostream &OS, const char *Name,
- const char *Title, bool ShowHidden = false) const;
+ void PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
+ bool ShowHidden = false, bool ShowAllAliases = false) const;
};
} // end namespace opt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35476.108229.patch
Type: text/x-patch
Size: 3145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170726/b68b9151/attachment.bin>
More information about the llvm-commits
mailing list