[PATCH] D51009: [opt] Make OptTable::PrintHelp append "[options] <inputs>" conditionally
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 20 16:19:43 PDT 2018
MaskRay updated this revision to Diff 161611.
MaskRay added a comment.
Newline
Repository:
rL LLVM
https://reviews.llvm.org/D51009
Files:
include/llvm/Option/OptTable.h
lib/Option/OptTable.cpp
Index: lib/Option/OptTable.cpp
===================================================================
--- lib/Option/OptTable.cpp
+++ lib/Option/OptTable.cpp
@@ -521,19 +521,21 @@
return getOptionHelpGroup(Opts, GroupID);
}
-void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
+void OptTable::PrintHelp(raw_ostream &OS, const char *NameOrUsage, const char *Title,
bool ShowHidden, bool ShowAllAliases) const {
- PrintHelp(OS, Name, Title, /*Include*/ 0, /*Exclude*/
+ PrintHelp(OS, NameOrUsage, Title, /*Include*/ 0, /*Exclude*/
(ShowHidden ? 0 : HelpHidden), ShowAllAliases);
}
-void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
+void OptTable::PrintHelp(raw_ostream &OS, const char *NameOrUsage, const char *Title,
unsigned FlagsToInclude, unsigned FlagsToExclude,
bool ShowAllAliases) const {
OS << "OVERVIEW: " << Title << "\n";
OS << '\n';
- OS << "USAGE: " << Name << " [options] <inputs>\n";
- OS << '\n';
+ OS << "USAGE: " << NameOrUsage;
+ if (!strchr(NameOrUsage, ' '))
+ OS << " [options] <inputs>";
+ OS << "\n\n";
// Render help text into a map of group-name to a list of (option, help)
// pairs.
Index: include/llvm/Option/OptTable.h
===================================================================
--- include/llvm/Option/OptTable.h
+++ include/llvm/Option/OptTable.h
@@ -217,20 +217,21 @@
/// Render the help text for an option table.
///
/// \param OS - The stream to write the help text to.
- /// \param Name - The name to use in the usage line.
+ /// \param NameOrUsage - The usage line. If without space, "[options] <inputs>"
+ /// will be appended.
/// \param Title - The title to use in the usage line.
/// \param FlagsToInclude - If non-zero, only include options with any
/// of these flags set.
/// \param FlagsToExclude - Exclude options with any of these flags set.
/// \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,
+ void PrintHelp(raw_ostream &OS, const char *NameOrUsage, const char *Title,
unsigned FlagsToInclude, unsigned FlagsToExclude,
bool ShowAllAliases) const;
- void PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
+ void PrintHelp(raw_ostream &OS, const char *NameOrUsage, const char *Title,
bool ShowHidden = false, bool ShowAllAliases = false) const;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51009.161611.patch
Type: text/x-patch
Size: 2821 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180820/dd9edabe/attachment.bin>
More information about the llvm-commits
mailing list