aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Driver/OptParser.td5
-rw-r--r--include/clang/Driver/OptTable.h22
-rw-r--r--lib/Driver/OptTable.cpp6
3 files changed, 25 insertions, 8 deletions
diff --git a/include/clang/Driver/OptParser.td b/include/clang/Driver/OptParser.td
index f5b6980d8f..286c4d2336 100644
--- a/include/clang/Driver/OptParser.td
+++ b/include/clang/Driver/OptParser.td
@@ -77,6 +77,11 @@ def RenderSeparate : OptionFlag;
// lines that use it.
def Unsupported : OptionFlag;
+// HelpHidden - The option should not be displayed in --help, even if it has
+// help text. Clients *can* use this in conjuction with the OptTable::PrintHelp
+// arguments to implement hidden help groups.
+def HelpHidden : OptionFlag;
+
// Define the option group class.
class OptionGroup<string name> {
diff --git a/include/clang/Driver/OptTable.h b/include/clang/Driver/OptTable.h
index ff2e108609..840e669a27 100644
--- a/include/clang/Driver/OptTable.h
+++ b/include/clang/Driver/OptTable.h
@@ -22,12 +22,13 @@ namespace driver {
namespace options {
enum DriverFlag {
DriverOption = (1 << 0),
- LinkerInput = (1 << 1),
- NoArgumentUnused = (1 << 2),
- RenderAsInput = (1 << 3),
- RenderJoined = (1 << 4),
- RenderSeparate = (1 << 5),
- Unsupported = (1 << 6)
+ HelpHidden = (1 << 1),
+ LinkerInput = (1 << 2),
+ NoArgumentUnused = (1 << 3),
+ RenderAsInput = (1 << 4),
+ RenderJoined = (1 << 5),
+ RenderSeparate = (1 << 6),
+ Unsupported = (1 << 7)
};
}
@@ -117,6 +118,12 @@ namespace options {
return getInfo(id).Kind;
}
+ /// isOptionHelpHidden - Should the help for the given option be hidden by
+ /// default.
+ bool isOptionHelpHidden(OptSpecifier id) const {
+ return getInfo(id).Flags & options::HelpHidden;
+ }
+
/// getOptionHelpText - Get the help text to use to describe this option.
const char *getOptionHelpText(OptSpecifier id) const {
return getInfo(id).HelpText;
@@ -166,8 +173,9 @@ namespace options {
/// \param OS - The stream to write the help text to.
/// \param Name - The name to use in the usage line.
/// \param Title - The title to use in the usage line.
+ /// \param ShowHidden - Whether help-hidden arguments should be shown.
void PrintHelp(llvm::raw_ostream &OS, const char *Name,
- const char *Title) const;
+ const char *Title, bool ShowHidden = false) const;
};
}
}
diff --git a/lib/Driver/OptTable.cpp b/lib/Driver/OptTable.cpp
index fc89cef14a..9c6c9b49ae 100644
--- a/lib/Driver/OptTable.cpp
+++ b/lib/Driver/OptTable.cpp
@@ -286,7 +286,7 @@ static std::string getOptionHelpName(const OptTable &Opts, OptSpecifier Id) {
}
void OptTable::PrintHelp(llvm::raw_ostream &OS, const char *Name,
- const char *Title) const {
+ const char *Title, bool ShowHidden) const {
OS << "OVERVIEW: " << Title << "\n";
OS << '\n';
OS << "USAGE: " << Name << " [options] <inputs>\n";
@@ -297,6 +297,10 @@ void OptTable::PrintHelp(llvm::raw_ostream &OS, const char *Name,
std::vector< std::pair<std::string, const char*> > OptionHelp;
for (unsigned i = 0, e = getNumOptions(); i != e; ++i) {
unsigned Id = i + 1;
+
+ if (!ShowHidden && isOptionHelpHidden(Id))
+ continue;
+
if (const char *Text = getOptionHelpText(Id))
OptionHelp.push_back(std::make_pair(getOptionHelpName(*this, Id), Text));
}