]> granicus.if.org Git - clang/commitdiff
OptParser: Add HelpHidden flag.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 4 Dec 2009 21:08:25 +0000 (21:08 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 4 Dec 2009 21:08:25 +0000 (21:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90591 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/OptParser.td
include/clang/Driver/OptTable.h
lib/Driver/OptTable.cpp

index f5b6980d8f6a1239cc18c21b6160f7fe9ed153f5..286c4d233686eb5c2d06425bac74e288ac72eb72 100644 (file)
@@ -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> {
index ff2e108609c09e3b905a75e0270f7dd29ee83623..840e669a27a8bbb9d82a64c16f544e8be2af818a 100644 (file)
@@ -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;
   };
 }
 }
index fc89cef14ac18d1fe7c2b5252d0d49396a580415..9c6c9b49ae98a8653d66137517798f65d0d5863d 100644 (file)
@@ -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));
   }