[llvm] r215770 - [Option] Support MultiArg in --help
Nick Kledzik
kledzik at apple.com
Fri Aug 15 14:35:07 PDT 2014
Author: kledzik
Date: Fri Aug 15 16:35:07 2014
New Revision: 215770
URL: http://llvm.org/viewvc/llvm-project?rev=215770&view=rev
Log:
[Option] Support MultiArg in --help
Currently, if you use a MultiArg<> option, then printing out the help/usage
message will cause an assert. This fixes getOptionHelpName() to work with
MultiArg Options.
Modified:
llvm/trunk/lib/Option/OptTable.cpp
Modified: llvm/trunk/lib/Option/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/OptTable.cpp?rev=215770&r1=215769&r2=215770&view=diff
==============================================================================
--- llvm/trunk/lib/Option/OptTable.cpp (original)
+++ llvm/trunk/lib/Option/OptTable.cpp Fri Aug 15 16:35:07 2014
@@ -300,7 +300,18 @@ static std::string getOptionHelpName(con
llvm_unreachable("Invalid option with help text.");
case Option::MultiArgClass:
- llvm_unreachable("Cannot print metavar for this kind of option.");
+ if (const char *MetaVarName = Opts.getOptionMetaVar(Id)) {
+ // For MultiArgs, metavar is full list of all argument names.
+ Name += ' ';
+ Name += MetaVarName;
+ }
+ else {
+ // For MultiArgs<N>, if metavar not supplied, print <value> N times.
+ for (unsigned i=0, e=O.getNumArgs(); i< e; ++i) {
+ Name += " <value>";
+ }
+ }
+ break;
case Option::FlagClass:
break;
More information about the llvm-commits
mailing list