[cfe-commits] r90591 - in /cfe/trunk: include/clang/Driver/OptParser.td include/clang/Driver/OptTable.h lib/Driver/OptTable.cpp

Daniel Dunbar daniel at zuster.org
Fri Dec 4 13:08:25 PST 2009


Author: ddunbar
Date: Fri Dec  4 15:08:25 2009
New Revision: 90591

URL: http://llvm.org/viewvc/llvm-project?rev=90591&view=rev
Log:
OptParser: Add HelpHidden flag.

Modified:
    cfe/trunk/include/clang/Driver/OptParser.td
    cfe/trunk/include/clang/Driver/OptTable.h
    cfe/trunk/lib/Driver/OptTable.cpp

Modified: cfe/trunk/include/clang/Driver/OptParser.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/OptParser.td?rev=90591&r1=90590&r2=90591&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/OptParser.td (original)
+++ cfe/trunk/include/clang/Driver/OptParser.td Fri Dec  4 15:08:25 2009
@@ -77,6 +77,11 @@
 // 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> {

Modified: cfe/trunk/include/clang/Driver/OptTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/OptTable.h?rev=90591&r1=90590&r2=90591&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/OptTable.h (original)
+++ cfe/trunk/include/clang/Driver/OptTable.h Fri Dec  4 15:08:25 2009
@@ -22,12 +22,13 @@
 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 @@
       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 @@
     /// \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;
   };
 }
 }

Modified: cfe/trunk/lib/Driver/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/OptTable.cpp?rev=90591&r1=90590&r2=90591&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/OptTable.cpp (original)
+++ cfe/trunk/lib/Driver/OptTable.cpp Fri Dec  4 15:08:25 2009
@@ -286,7 +286,7 @@
 }
 
 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 @@
   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));
   }





More information about the cfe-commits mailing list