summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Option/OptTable.cpp
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2014-08-15 21:35:07 +0000
committerNick Kledzik <kledzik@apple.com>2014-08-15 21:35:07 +0000
commitbcd6e2a94334f9394d9133f4d2045d04a253ae74 (patch)
treef93a89f484d53731c8879d77e8fbee3a9b869294 /llvm/lib/Option/OptTable.cpp
parentf11170406e86e76aafa0c5f567594ba44f5f1dd9 (diff)
downloadbcm5719-llvm-bcd6e2a94334f9394d9133f4d2045d04a253ae74.tar.gz
bcm5719-llvm-bcd6e2a94334f9394d9133f4d2045d04a253ae74.zip
[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. llvm-svn: 215770
Diffstat (limited to 'llvm/lib/Option/OptTable.cpp')
-rw-r--r--llvm/lib/Option/OptTable.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp
index 6842f4d5791..ef9a3e75a15 100644
--- a/llvm/lib/Option/OptTable.cpp
+++ b/llvm/lib/Option/OptTable.cpp
@@ -300,7 +300,18 @@ static std::string getOptionHelpName(const OptTable &Opts, OptSpecifier Id) {
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;
OpenPOWER on IntegriCloud