diff options
author | Chris Lattner <sabre@nondot.org> | 2002-01-31 00:42:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-01-31 00:42:56 +0000 |
commit | 9c9be48b8396e7244e47d2af8890da8eec71c72d (patch) | |
tree | 01da5493689cc6952c27b86663633f4a9bf5ab5d /support | |
parent | 93193f806378e06092820c099e437886c7309b94 (diff) | |
download | external_llvm-9c9be48b8396e7244e47d2af8890da8eec71c72d.zip external_llvm-9c9be48b8396e7244e47d2af8890da8eec71c72d.tar.gz external_llvm-9c9be48b8396e7244e47d2af8890da8eec71c72d.tar.bz2 |
If an invalid alternative is listed for an argument, print the valid options
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1604 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'support')
-rw-r--r-- | support/lib/Support/CommandLine.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 549f42c..d396627 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -34,7 +34,7 @@ static map<string, Option*> &getOpts() { static void AddArgument(const string &ArgName, Option *Opt) { if (getOpts().find(ArgName) != getOpts().end()) { cerr << "CommandLine Error: Argument '" << ArgName - << "' specified more than once!\n"; + << "' defined more than once!\n"; } else { // Add argument to the argument map! getOpts().insert(std::make_pair(ArgName, Opt)); @@ -335,8 +335,17 @@ bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned i; for (i = 0; i < ValueMap.size(); ++i) if (ValueMap[i].first == Arg) break; - if (i == ValueMap.size()) - return error(": unrecognized alternative '"+Arg+"'!"); + + if (i == ValueMap.size()) { + string Alternatives; + for (i = 0; i < ValueMap.size(); ++i) { + if (i) Alternatives += ", "; + Alternatives += ValueMap[i].first; + } + + return error(": unrecognized alternative '" + Arg + + "'! Alternatives are: " + Alternatives); + } Value = ValueMap[i].second.first; return false; } |