aboutsummaryrefslogtreecommitdiffstats
path: root/source/Interpreter/OptionArgParser.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:06:29 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:06:29 +0000
commit94994d372d014ce4c8758b9605d63fae651bd8aa (patch)
tree51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /source/Interpreter/OptionArgParser.cpp
parent39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff)
downloadsrc-94994d372d014ce4c8758b9605d63fae651bd8aa.tar.gz
src-94994d372d014ce4c8758b9605d63fae651bd8aa.zip
Vendor import of lldb trunk r351319 (just before the release_80 branchvendor/lldb/lldb-trunk-r351319
Notes
Notes: svn path=/vendor/lldb/dist/; revision=343181 svn path=/vendor/lldb/lldb-trunk-r351319/; revision=343182; tag=vendor/lldb/lldb-trunk-r351319
Diffstat (limited to 'source/Interpreter/OptionArgParser.cpp')
-rw-r--r--source/Interpreter/OptionArgParser.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/source/Interpreter/OptionArgParser.cpp b/source/Interpreter/OptionArgParser.cpp
index 3bd3af8fc50e..b0565b706c5b 100644
--- a/source/Interpreter/OptionArgParser.cpp
+++ b/source/Interpreter/OptionArgParser.cpp
@@ -46,10 +46,10 @@ char OptionArgParser::ToChar(llvm::StringRef s, char fail_value,
}
int64_t OptionArgParser::ToOptionEnum(llvm::StringRef s,
- OptionEnumValueElement *enum_values,
+ const OptionEnumValues &enum_values,
int32_t fail_value, Status &error) {
error.Clear();
- if (!enum_values) {
+ if (enum_values.empty()) {
error.SetErrorString("invalid enumeration argument");
return fail_value;
}
@@ -59,16 +59,18 @@ int64_t OptionArgParser::ToOptionEnum(llvm::StringRef s,
return fail_value;
}
- for (int i = 0; enum_values[i].string_value != nullptr; i++) {
- llvm::StringRef this_enum(enum_values[i].string_value);
+ for (const auto &enum_value : enum_values) {
+ llvm::StringRef this_enum(enum_value.string_value);
if (this_enum.startswith(s))
- return enum_values[i].value;
+ return enum_value.value;
}
StreamString strm;
strm.PutCString("invalid enumeration value, valid values are: ");
- for (int i = 0; enum_values[i].string_value != nullptr; i++) {
- strm.Printf("%s\"%s\"", i > 0 ? ", " : "", enum_values[i].string_value);
+ bool is_first = true;
+ for (const auto &enum_value : enum_values) {
+ strm.Printf("%s\"%s\"",
+ is_first ? is_first = false,"" : ", ", enum_value.string_value);
}
error.SetErrorString(strm.GetString());
return fail_value;