diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-10-08 19:41:06 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-10-08 19:41:06 +0000 |
commit | 3ffe113e11168abcd809ec5ac539538ade5db0cb (patch) | |
tree | 940834485282186ad96a5374085e5f2014c2cf95 /docs/CommandLine.rst | |
parent | 49695dd279f271636ba2a1be19ba13c6e3f9be74 (diff) |
Turn cl::values() (for enum) from a vararg function to using C++ variadic template
The core of the change is supposed to be NFC, however it also fixes
what I believe was an undefined behavior when calling:
va_start(ValueArgs, Desc);
with Desc being a StringRef.
Differential Revision: https://reviews.llvm.org/D25342
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283671 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/CommandLine.rst')
-rw-r--r-- | docs/CommandLine.rst | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/docs/CommandLine.rst b/docs/CommandLine.rst index 556c302501e..66a96eefbae 100644 --- a/docs/CommandLine.rst +++ b/docs/CommandLine.rst @@ -355,8 +355,7 @@ library fill it in with the appropriate level directly, which is used like this: clEnumVal(g , "No optimizations, enable debugging"), clEnumVal(O1, "Enable trivial optimizations"), clEnumVal(O2, "Enable default optimizations"), - clEnumVal(O3, "Enable expensive optimizations"), - clEnumValEnd)); + clEnumVal(O3, "Enable expensive optimizations"))); ... if (OptimizationLevel >= O2) doPartialRedundancyElimination(...); @@ -401,8 +400,7 @@ program. Because of this, we can alternatively write this example like this: clEnumValN(Debug, "g", "No optimizations, enable debugging"), clEnumVal(O1 , "Enable trivial optimizations"), clEnumVal(O2 , "Enable default optimizations"), - clEnumVal(O3 , "Enable expensive optimizations"), - clEnumValEnd)); + clEnumVal(O3 , "Enable expensive optimizations"))); ... if (OptimizationLevel == Debug) outputDebugInfo(...); @@ -436,8 +434,7 @@ the code looks like this: cl::values( clEnumValN(nodebuginfo, "none", "disable debug information"), clEnumVal(quick, "enable quick debug information"), - clEnumVal(detailed, "enable detailed debug information"), - clEnumValEnd)); + clEnumVal(detailed, "enable detailed debug information"))); This definition defines an enumerated command line variable of type "``enum DebugLev``", which works exactly the same way as before. The difference here is @@ -498,8 +495,7 @@ Then define your "``cl::list``" variable: clEnumVal(dce , "Dead Code Elimination"), clEnumVal(constprop , "Constant Propagation"), clEnumValN(inlining, "inline", "Procedure Integration"), - clEnumVal(strip , "Strip Symbols"), - clEnumValEnd)); + clEnumVal(strip , "Strip Symbols"))); This defines a variable that is conceptually of the type "``std::vector<enum Opts>``". Thus, you can access it with standard vector @@ -558,8 +554,7 @@ Reworking the above list example, we could replace `cl::list`_ with `cl::bits`_: clEnumVal(dce , "Dead Code Elimination"), clEnumVal(constprop , "Constant Propagation"), clEnumValN(inlining, "inline", "Procedure Integration"), - clEnumVal(strip , "Strip Symbols"), - clEnumValEnd)); + clEnumVal(strip , "Strip Symbols"))); To test to see if ``constprop`` was specified, we can use the ``cl:bits::isSet`` function: |