[PATCH] D33861: [CommandLine] Fix Tutorial Documentation for Command Line Library

bekket mcclane via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 3 05:51:51 PDT 2017


mshockwave created this revision.

In the command line library, `cl::values` should be end by null, or `clEnumValEnd`. However, the tutorial page <http://llvm.org/docs/CommandLine.html> for it doesn't follow the rule.
Example codes are fixed and some description text is added in this patch.


https://reviews.llvm.org/D33861

Files:
  docs/CommandLine.rst


Index: docs/CommandLine.rst
===================================================================
--- docs/CommandLine.rst
+++ docs/CommandLine.rst
@@ -355,7 +355,7 @@
       clEnumVal(g , "No optimizations, enable debugging"),
       clEnumVal(O1, "Enable trivial optimizations"),
       clEnumVal(O2, "Enable default optimizations"),
-      clEnumVal(O3, "Enable expensive optimizations")));
+      clEnumVal(O3, "Enable expensive optimizations"), clEnumValEnd));
 
   ...
     if (OptimizationLevel >= O2) doPartialRedundancyElimination(...);
@@ -366,8 +366,9 @@
 are listed in the declaration.  The CommandLine library enforces that
 the user can only specify one of the options, and it ensure that only valid enum
 values can be specified.  The "``clEnumVal``" macros ensure that the command
-line arguments matched the enum values.  With this option added, our help output
-now is:
+line arguments matched the enum values, and always remember to add "``clEnumValEnd``" 
+at the end since argument list for "``cl::values``" should be end with null.  
+With this option added, our help output now is:
 
 ::
 
@@ -399,7 +400,7 @@
      clEnumValN(Debug, "g", "No optimizations, enable debugging"),
       clEnumVal(O1        , "Enable trivial optimizations"),
       clEnumVal(O2        , "Enable default optimizations"),
-      clEnumVal(O3        , "Enable expensive optimizations")));
+      clEnumVal(O3        , "Enable expensive optimizations"), clEnumValEnd));
 
   ...
     if (OptimizationLevel == Debug) outputDebugInfo(...);
@@ -433,7 +434,8 @@
     cl::values(
       clEnumValN(nodebuginfo, "none", "disable debug information"),
        clEnumVal(quick,               "enable quick debug information"),
-       clEnumVal(detailed,            "enable detailed debug information")));
+       clEnumVal(detailed,            "enable detailed debug information"),
+       clEnumValEnd));
 
 This definition defines an enumerated command line variable of type "``enum
 DebugLev``", which works exactly the same way as before.  The difference here is
@@ -494,7 +496,7 @@
       clEnumVal(dce               , "Dead Code Elimination"),
       clEnumVal(constprop         , "Constant Propagation"),
      clEnumValN(inlining, "inline", "Procedure Integration"),
-      clEnumVal(strip             , "Strip Symbols")));
+      clEnumVal(strip             , "Strip Symbols"), clEnumValEnd));
 
 This defines a variable that is conceptually of the type
 "``std::vector<enum Opts>``".  Thus, you can access it with standard vector
@@ -553,7 +555,7 @@
       clEnumVal(dce               , "Dead Code Elimination"),
       clEnumVal(constprop         , "Constant Propagation"),
      clEnumValN(inlining, "inline", "Procedure Integration"),
-      clEnumVal(strip             , "Strip Symbols")));
+      clEnumVal(strip             , "Strip Symbols"), clEnumValEnd));
 
 To test to see if ``constprop`` was specified, we can use the ``cl:bits::isSet``
 function:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33861.101313.patch
Type: text/x-patch
Size: 2962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170603/b098a2cf/attachment.bin>


More information about the llvm-commits mailing list