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/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;
       }
     }