Replace "nullptr-terminated" C-arrays of OptionValueEnumeration with safer llvm::ArrayRef

Differential Revision: https://reviews.llvm.org/D49017

llvm-svn: 343130
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 6cc5da5..77fdeb1 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -76,22 +76,21 @@
 
 static const char *k_white_space = " \t\v";
 
-static PropertyDefinition g_properties[] = {
+static constexpr PropertyDefinition g_properties[] = {
     {"expand-regex-aliases", OptionValue::eTypeBoolean, true, false, nullptr,
-     nullptr, "If true, regular expression alias commands will show the "
+     {}, "If true, regular expression alias commands will show the "
               "expanded command that will be executed. This can be used to "
               "debug new regular expression alias commands."},
-    {"prompt-on-quit", OptionValue::eTypeBoolean, true, true, nullptr, nullptr,
+    {"prompt-on-quit", OptionValue::eTypeBoolean, true, true, nullptr, {},
      "If true, LLDB will prompt you before quitting if there are any live "
      "processes being debugged. If false, LLDB will quit without asking in any "
      "case."},
     {"stop-command-source-on-error", OptionValue::eTypeBoolean, true, true,
-     nullptr, nullptr, "If true, LLDB will stop running a 'command source' "
-                       "script upon encountering an error."},
-    {"space-repl-prompts", OptionValue::eTypeBoolean, true, false, nullptr,
-     nullptr,
+     nullptr, {}, "If true, LLDB will stop running a 'command source' "
+                  "script upon encountering an error."},
+    {"space-repl-prompts", OptionValue::eTypeBoolean, true, false, nullptr, {},
      "If true, blank lines will be printed between between REPL submissions."},
-    {nullptr, OptionValue::eTypeInvalid, true, 0, nullptr, nullptr, nullptr}};
+    {nullptr, OptionValue::eTypeInvalid, true, 0, nullptr, {}, nullptr}};
 
 enum {
   ePropertyExpandRegexAliases = 0,
diff --git a/lldb/source/Interpreter/OptionArgParser.cpp b/lldb/source/Interpreter/OptionArgParser.cpp
index 3bd3af8..b0565b7 100644
--- a/lldb/source/Interpreter/OptionArgParser.cpp
+++ b/lldb/source/Interpreter/OptionArgParser.cpp
@@ -46,10 +46,10 @@
 }
 
 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 @@
     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;
diff --git a/lldb/source/Interpreter/OptionGroupArchitecture.cpp b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
index bbd69b8..42eafc9 100644
--- a/lldb/source/Interpreter/OptionGroupArchitecture.cpp
+++ b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
@@ -18,9 +18,9 @@
 
 OptionGroupArchitecture::~OptionGroupArchitecture() {}
 
-static OptionDefinition g_option_table[] = {
+static constexpr OptionDefinition g_option_table[] = {
     {LLDB_OPT_SET_1, false, "arch", 'a', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeArchitecture,
+     nullptr, {}, 0, eArgTypeArchitecture,
      "Specify the architecture for the target."},
 };
 
diff --git a/lldb/source/Interpreter/OptionGroupBoolean.cpp b/lldb/source/Interpreter/OptionGroupBoolean.cpp
index e3759f2..37c63f6 100644
--- a/lldb/source/Interpreter/OptionGroupBoolean.cpp
+++ b/lldb/source/Interpreter/OptionGroupBoolean.cpp
@@ -32,7 +32,7 @@
   m_option_definition.option_has_arg = no_argument_toggle_default
                                            ? OptionParser::eNoArgument
                                            : OptionParser::eRequiredArgument;
-  m_option_definition.enum_values = nullptr;
+  m_option_definition.enum_values = {};
   m_option_definition.completion_type = 0;
   m_option_definition.argument_type = eArgTypeBoolean;
   m_option_definition.usage_text = usage_text;
diff --git a/lldb/source/Interpreter/OptionGroupFile.cpp b/lldb/source/Interpreter/OptionGroupFile.cpp
index d45f00a..72ec4cb 100644
--- a/lldb/source/Interpreter/OptionGroupFile.cpp
+++ b/lldb/source/Interpreter/OptionGroupFile.cpp
@@ -30,7 +30,7 @@
   m_option_definition.short_option = short_option;
   m_option_definition.validator = nullptr;
   m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
-  m_option_definition.enum_values = nullptr;
+  m_option_definition.enum_values = {};
   m_option_definition.completion_type = completion_type;
   m_option_definition.argument_type = argument_type;
   m_option_definition.usage_text = usage_text;
@@ -61,7 +61,7 @@
   m_option_definition.short_option = short_option;
   m_option_definition.validator = nullptr;
   m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
-  m_option_definition.enum_values = nullptr;
+  m_option_definition.enum_values = {};
   m_option_definition.completion_type = completion_type;
   m_option_definition.argument_type = argument_type;
   m_option_definition.usage_text = usage_text;
diff --git a/lldb/source/Interpreter/OptionGroupFormat.cpp b/lldb/source/Interpreter/OptionGroupFormat.cpp
index b64c193..6345a63 100644
--- a/lldb/source/Interpreter/OptionGroupFormat.cpp
+++ b/lldb/source/Interpreter/OptionGroupFormat.cpp
@@ -27,18 +27,18 @@
 
 OptionGroupFormat::~OptionGroupFormat() {}
 
-static OptionDefinition g_option_table[] = {
+static constexpr OptionDefinition g_option_table[] = {
     {LLDB_OPT_SET_1, false, "format", 'f', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeFormat,
+     nullptr, {}, 0, eArgTypeFormat,
      "Specify a format to be used for display."},
     {LLDB_OPT_SET_2, false, "gdb-format", 'G', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeGDBFormat,
+     nullptr, {}, 0, eArgTypeGDBFormat,
      "Specify a format using a GDB format specifier string."},
     {LLDB_OPT_SET_3, false, "size", 's', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeByteSize,
+     nullptr, {}, 0, eArgTypeByteSize,
      "The size in bytes to use when displaying with the selected format."},
     {LLDB_OPT_SET_4, false, "count", 'c', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeCount,
+     nullptr, {}, 0, eArgTypeCount,
      "The number of total items to display."},
 };
 
diff --git a/lldb/source/Interpreter/OptionGroupOutputFile.cpp b/lldb/source/Interpreter/OptionGroupOutputFile.cpp
index fd40649..143a293 100644
--- a/lldb/source/Interpreter/OptionGroupOutputFile.cpp
+++ b/lldb/source/Interpreter/OptionGroupOutputFile.cpp
@@ -25,12 +25,12 @@
 
 static const uint32_t SHORT_OPTION_APND = 0x61706e64; // 'apnd'
 
-static OptionDefinition g_option_table[] = {
+static constexpr OptionDefinition g_option_table[] = {
     {LLDB_OPT_SET_1, false, "outfile", 'o', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeFilename,
+     nullptr, {}, 0, eArgTypeFilename,
      "Specify a path for capturing command output."},
     {LLDB_OPT_SET_1, false, "append-outfile", SHORT_OPTION_APND,
-     OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
+     OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone,
      "Append to the file specified with '--outfile <path>'."},
 };
 
diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp
index 4797427..c0d24a5 100644
--- a/lldb/source/Interpreter/OptionGroupPlatform.cpp
+++ b/lldb/source/Interpreter/OptionGroupPlatform.cpp
@@ -65,21 +65,21 @@
   m_os_version = llvm::VersionTuple();
 }
 
-static OptionDefinition g_option_table[] = {
+static constexpr OptionDefinition g_option_table[] = {
     {LLDB_OPT_SET_ALL, false, "platform", 'p', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypePlatform, "Specify name of the platform to "
-                                            "use for this target, creating the "
-                                            "platform if necessary."},
+     nullptr, {}, 0, eArgTypePlatform, "Specify name of the platform to "
+                                       "use for this target, creating the "
+                                       "platform if necessary."},
     {LLDB_OPT_SET_ALL, false, "version", 'v', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeNone,
+     nullptr, {}, 0, eArgTypeNone,
      "Specify the initial SDK version to use prior to connecting."},
     {LLDB_OPT_SET_ALL, false, "build", 'b', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeNone,
+     nullptr, {}, 0, eArgTypeNone,
      "Specify the initial SDK build number."},
     {LLDB_OPT_SET_ALL, false, "sysroot", 'S', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeFilename, "Specify the SDK root directory "
-                                            "that contains a root of all "
-                                            "remote system files."}};
+     nullptr, {}, 0, eArgTypeFilename, "Specify the SDK root directory "
+                                       "that contains a root of all "
+                                       "remote system files."}};
 
 llvm::ArrayRef<OptionDefinition> OptionGroupPlatform::GetDefinitions() {
   llvm::ArrayRef<OptionDefinition> result(g_option_table);
diff --git a/lldb/source/Interpreter/OptionGroupString.cpp b/lldb/source/Interpreter/OptionGroupString.cpp
index 1a16194..badcfbe 100644
--- a/lldb/source/Interpreter/OptionGroupString.cpp
+++ b/lldb/source/Interpreter/OptionGroupString.cpp
@@ -31,7 +31,7 @@
   m_option_definition.short_option = short_option;
   m_option_definition.validator = nullptr;
   m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
-  m_option_definition.enum_values = nullptr;
+  m_option_definition.enum_values = {};
   m_option_definition.completion_type = completion_type;
   m_option_definition.argument_type = argument_type;
   m_option_definition.usage_text = usage_text;
diff --git a/lldb/source/Interpreter/OptionGroupUInt64.cpp b/lldb/source/Interpreter/OptionGroupUInt64.cpp
index ae4828c..252308b 100644
--- a/lldb/source/Interpreter/OptionGroupUInt64.cpp
+++ b/lldb/source/Interpreter/OptionGroupUInt64.cpp
@@ -31,7 +31,7 @@
   m_option_definition.short_option = short_option;
   m_option_definition.validator = nullptr;
   m_option_definition.option_has_arg = OptionParser::eRequiredArgument;
-  m_option_definition.enum_values = nullptr;
+  m_option_definition.enum_values = {};
   m_option_definition.completion_type = completion_type;
   m_option_definition.argument_type = argument_type;
   m_option_definition.usage_text = usage_text;
diff --git a/lldb/source/Interpreter/OptionGroupUUID.cpp b/lldb/source/Interpreter/OptionGroupUUID.cpp
index bf02d1b..b58f269 100644
--- a/lldb/source/Interpreter/OptionGroupUUID.cpp
+++ b/lldb/source/Interpreter/OptionGroupUUID.cpp
@@ -22,9 +22,9 @@
 
 OptionGroupUUID::~OptionGroupUUID() {}
 
-static OptionDefinition g_option_table[] = {
+static constexpr OptionDefinition g_option_table[] = {
     {LLDB_OPT_SET_1, false, "uuid", 'u', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeNone, "A module UUID value."},
+     nullptr, {}, 0, eArgTypeNone, "A module UUID value."},
 };
 
 llvm::ArrayRef<OptionDefinition> OptionGroupUUID::GetDefinitions() {
diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 54b45c2..d431431 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -28,46 +28,44 @@
 
 OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay() {}
 
-static OptionDefinition g_option_table[] = {
+static const OptionDefinition g_option_table[] = {
     {LLDB_OPT_SET_1, false, "dynamic-type", 'd',
-     OptionParser::eRequiredArgument, nullptr, g_dynamic_value_types, 0,
+     OptionParser::eRequiredArgument, nullptr, GetDynamicValueTypes(), 0,
      eArgTypeNone, "Show the object as its full dynamic type, not its static "
                    "type, if available."},
     {LLDB_OPT_SET_1, false, "synthetic-type", 'S',
-     OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
+     OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean,
      "Show the object obeying its synthetic provider, if available."},
     {LLDB_OPT_SET_1, false, "depth", 'D', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeCount, "Set the max recurse depth when "
-                                         "dumping aggregate types (default is "
-                                         "infinity)."},
+     nullptr, {}, 0, eArgTypeCount, "Set the max recurse depth when dumping "
+                                    "aggregate types (default is infinity)."},
     {LLDB_OPT_SET_1, false, "flat", 'F', OptionParser::eNoArgument, nullptr,
-     nullptr, 0, eArgTypeNone, "Display results in a flat format that uses "
-                               "expression paths for each variable or member."},
+     {}, 0, eArgTypeNone, "Display results in a flat format that uses "
+                          "expression paths for each variable or member."},
     {LLDB_OPT_SET_1, false, "location", 'L', OptionParser::eNoArgument, nullptr,
-     nullptr, 0, eArgTypeNone, "Show variable location information."},
+     {}, 0, eArgTypeNone, "Show variable location information."},
     {LLDB_OPT_SET_1, false, "object-description", 'O',
-     OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
+     OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone,
      "Print as an Objective-C object."},
     {LLDB_OPT_SET_1, false, "ptr-depth", 'P', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeCount, "The number of pointers to be "
-                                         "traversed when dumping values "
-                                         "(default is zero)."},
+     nullptr, {}, 0, eArgTypeCount, "The number of pointers to be traversed "
+                                    "when dumping values (default is zero)."},
     {LLDB_OPT_SET_1, false, "show-types", 'T', OptionParser::eNoArgument,
-     nullptr, nullptr, 0, eArgTypeNone,
+     nullptr, {}, 0, eArgTypeNone,
      "Show variable types when dumping values."},
     {LLDB_OPT_SET_1, false, "no-summary-depth", 'Y',
-     OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypeCount,
+     OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeCount,
      "Set the depth at which omitting summary information stops (default is "
      "1)."},
     {LLDB_OPT_SET_1, false, "raw-output", 'R', OptionParser::eNoArgument,
-     nullptr, nullptr, 0, eArgTypeNone, "Don't use formatting options."},
+     nullptr, {}, 0, eArgTypeNone, "Don't use formatting options."},
     {LLDB_OPT_SET_1, false, "show-all-children", 'A', OptionParser::eNoArgument,
-     nullptr, nullptr, 0, eArgTypeNone,
+     nullptr, {}, 0, eArgTypeNone,
      "Ignore the upper bound on the number of children to show."},
     {LLDB_OPT_SET_1, false, "validate", 'V', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeBoolean, "Show results of type validators."},
+     nullptr, {}, 0, eArgTypeBoolean, "Show results of type validators."},
     {LLDB_OPT_SET_1, false, "element-count", 'Z',
-     OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeCount,
+     OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount,
      "Treat the result of the expression as if its type is an array of this "
      "many values."}};
 
@@ -86,8 +84,8 @@
   switch (short_option) {
   case 'd': {
     int32_t result;
-    result = OptionArgParser::ToOptionEnum(option_arg, g_dynamic_value_types, 2,
-                                           error);
+    result = OptionArgParser::ToOptionEnum(option_arg, GetDynamicValueTypes(),
+                                           2, error);
     if (error.Success())
       use_dynamic = (lldb::DynamicValueType)result;
   } break;
diff --git a/lldb/source/Interpreter/OptionGroupVariable.cpp b/lldb/source/Interpreter/OptionGroupVariable.cpp
index 7b7a62b..1bcddb4 100644
--- a/lldb/source/Interpreter/OptionGroupVariable.cpp
+++ b/lldb/source/Interpreter/OptionGroupVariable.cpp
@@ -24,31 +24,31 @@
 
 // if you add any options here, remember to update the counters in
 // OptionGroupVariable::GetNumDefinitions()
-static OptionDefinition g_variable_options[] = {
+static constexpr OptionDefinition g_variable_options[] = {
     {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-args", 'a',
-     OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
+     OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone,
      "Omit function arguments."},
     {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "no-locals", 'l',
-     OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
+     OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone,
      "Omit local variables."},
     {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-globals", 'g',
-     OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
+     OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone,
      "Show the current frame source file global and static variables."},
     {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "show-declaration", 'c',
-     OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
+     OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone,
      "Show variable declaration information (source file and line where the "
      "variable was declared)."},
     {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "regex", 'r',
-     OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeRegularExpression,
+     OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeRegularExpression,
      "The <variable-name> argument for name lookups are regular expressions."},
     {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "scope", 's',
-     OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
+     OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone,
      "Show variable scope (argument, local, global, static)."},
     {LLDB_OPT_SET_1, false, "summary", 'y', OptionParser::eRequiredArgument,
-     nullptr, nullptr, 0, eArgTypeName,
+     nullptr, {}, 0, eArgTypeName,
      "Specify the summary that the variable output should use."},
     {LLDB_OPT_SET_2, false, "summary-string", 'z',
-     OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeName,
+     OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName,
      "Specify a summary string to use to format the variable output."},
 };
 
diff --git a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
index 0431fef..6cfcf18 100644
--- a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
+++ b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -20,33 +20,31 @@
 using namespace lldb;
 using namespace lldb_private;
 
-static OptionEnumValueElement g_watch_type[] = {
+static constexpr OptionEnumValueElement g_watch_type[] = {
     {OptionGroupWatchpoint::eWatchRead, "read", "Watch for read"},
     {OptionGroupWatchpoint::eWatchWrite, "write", "Watch for write"},
     {OptionGroupWatchpoint::eWatchReadWrite, "read_write",
-     "Watch for read/write"},
-    {0, nullptr, nullptr}};
+     "Watch for read/write"} };
 
-static OptionEnumValueElement g_watch_size[] = {
+static constexpr OptionEnumValueElement g_watch_size[] = {
     {1, "1", "Watch for byte size of 1"},
     {2, "2", "Watch for byte size of 2"},
     {4, "4", "Watch for byte size of 4"},
-    {8, "8", "Watch for byte size of 8"},
-    {0, nullptr, nullptr}};
+    {8, "8", "Watch for byte size of 8"} };
 
-static OptionDefinition g_option_table[] = {
+static constexpr OptionDefinition g_option_table[] = {
     {LLDB_OPT_SET_1, false, "watch", 'w', OptionParser::eRequiredArgument,
-     nullptr, g_watch_type, 0, eArgTypeWatchType,
+     nullptr, OptionEnumValues(g_watch_type), 0, eArgTypeWatchType,
      "Specify the type of watching to perform."},
     {LLDB_OPT_SET_1, false, "size", 's', OptionParser::eRequiredArgument,
-     nullptr, g_watch_size, 0, eArgTypeByteSize,
+     nullptr, OptionEnumValues(g_watch_size), 0, eArgTypeByteSize,
      "Number of bytes to use to watch a region."}};
 
 bool OptionGroupWatchpoint::IsWatchSizeSupported(uint32_t watch_size) {
-  for (uint32_t i = 0; i < llvm::array_lengthof(g_watch_size); ++i) {
-    if (g_watch_size[i].value == 0)
+  for (const auto& size : g_watch_size) {
+    if (0  == size.value)
       break;
-    if (watch_size == g_watch_size[i].value)
+    if (watch_size == size.value)
       return true;
   }
   return false;
diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp
index c7cbcab..25e85c6 100644
--- a/lldb/source/Interpreter/OptionValueEnumeration.cpp
+++ b/lldb/source/Interpreter/OptionValueEnumeration.cpp
@@ -19,7 +19,7 @@
 using namespace lldb_private;
 
 OptionValueEnumeration::OptionValueEnumeration(
-    const OptionEnumValueElement *enumerators, enum_type value)
+    const OptionEnumValues &enumerators, enum_type value)
     : OptionValue(), m_current_value(value), m_default_value(value),
       m_enumerations() {
   SetEnumerations(enumerators);
@@ -91,18 +91,16 @@
 }
 
 void OptionValueEnumeration::SetEnumerations(
-    const OptionEnumValueElement *enumerators) {
+    const OptionEnumValues &enumerators) {
   m_enumerations.Clear();
-  if (enumerators) {
-    for (size_t i = 0; enumerators[i].string_value != nullptr; ++i) {
-      ConstString const_enumerator_name(enumerators[i].string_value);
-      EnumeratorInfo enumerator_info = {enumerators[i].value,
-                                        enumerators[i].usage};
-      m_enumerations.Append(const_enumerator_name,
-                            enumerator_info);
-    }
-    m_enumerations.Sort();
+
+  for (const auto &enumerator : enumerators) {
+    ConstString const_enumerator_name(enumerator.string_value);
+    EnumeratorInfo enumerator_info = {enumerator.value, enumerator.usage};
+    m_enumerations.Append(const_enumerator_name, enumerator_info);
   }
+
+  m_enumerations.Sort();
 }
 
 lldb::OptionValueSP OptionValueEnumeration::DeepCopy() const {
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index c9567e9..bdea5b4 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -601,15 +601,17 @@
 
       if (opt_defs[i].usage_text)
         OutputFormattedUsageText(strm, opt_defs[i], screen_width);
-      if (opt_defs[i].enum_values != nullptr) {
+      if (!opt_defs[i].enum_values.empty()) {
         strm.Indent();
         strm.Printf("Values: ");
-        for (int k = 0; opt_defs[i].enum_values[k].string_value != nullptr;
-             k++) {
-          if (k == 0)
-            strm.Printf("%s", opt_defs[i].enum_values[k].string_value);
+        bool is_first = true;
+        for (const auto &enum_value : opt_defs[i].enum_values) {
+          if (is_first) {
+            strm.Printf("%s", enum_value.string_value);
+            is_first = false;
+          }
           else
-            strm.Printf(" | %s", opt_defs[i].enum_values[k].string_value);
+            strm.Printf(" | %s", enum_value.string_value);
         }
         strm.EOL();
       }
@@ -770,17 +772,18 @@
 
   // See if this is an enumeration type option, and if so complete it here:
 
-  OptionEnumValueElement *enum_values = opt_defs[opt_defs_index].enum_values;
-  if (enum_values != nullptr) {
+  const auto &enum_values = opt_defs[opt_defs_index].enum_values;
+  if (!enum_values.empty()) {
     bool return_value = false;
     std::string match_string(
         request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos),
         request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos) +
             request.GetCursorCharPosition());
-    for (int i = 0; enum_values[i].string_value != nullptr; i++) {
-      if (strstr(enum_values[i].string_value, match_string.c_str()) ==
-          enum_values[i].string_value) {
-        request.AddCompletion(enum_values[i].string_value);
+
+    for (const auto &enum_value : enum_values) {
+      if (strstr(enum_value.string_value, match_string.c_str()) ==
+          enum_value.string_value) {
+        request.AddCompletion(enum_value.string_value);
         return_value = true;
       }
     }