Use llvm::ArrayRef rather than std::vector/std::initializer lists for some
ValueObject methods.

Using ArrayRef allows us to remove some overloads, work with more array-like
types, and avoid some std::vector temporaries.

https://reviews.llvm.org/D32518

llvm-svn: 301441
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index 1c923f3..0898754b 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -27,6 +27,7 @@
 #include "lldb/lldb-private-enumerations.h" // for AddressType
 #include "lldb/lldb-types.h"                // for addr_t, offs...
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h" // for StringRef
@@ -37,7 +38,6 @@
 #include <mutex>   // for recursive_mutex
 #include <string>  // for string
 #include <utility> // for pair
-#include <vector>
 
 #include <stddef.h> // for size_t
 #include <stdint.h> // for uint32_t
@@ -489,35 +489,19 @@
   virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create);
 
   // this will always create the children if necessary
-  lldb::ValueObjectSP
-  GetChildAtIndexPath(const std::initializer_list<size_t> &idxs,
-                      size_t *index_of_error = nullptr);
-
-  lldb::ValueObjectSP GetChildAtIndexPath(const std::vector<size_t> &idxs,
+  lldb::ValueObjectSP GetChildAtIndexPath(llvm::ArrayRef<size_t> idxs,
                                           size_t *index_of_error = nullptr);
 
-  lldb::ValueObjectSP GetChildAtIndexPath(
-      const std::initializer_list<std::pair<size_t, bool>> &idxs,
-      size_t *index_of_error = nullptr);
-
   lldb::ValueObjectSP
-  GetChildAtIndexPath(const std::vector<std::pair<size_t, bool>> &idxs,
+  GetChildAtIndexPath(llvm::ArrayRef<std::pair<size_t, bool>> idxs,
                       size_t *index_of_error = nullptr);
 
   // this will always create the children if necessary
-  lldb::ValueObjectSP
-  GetChildAtNamePath(const std::initializer_list<ConstString> &names,
-                     ConstString *name_of_error = nullptr);
-
-  lldb::ValueObjectSP GetChildAtNamePath(const std::vector<ConstString> &names,
+  lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef<ConstString> names,
                                          ConstString *name_of_error = nullptr);
 
-  lldb::ValueObjectSP GetChildAtNamePath(
-      const std::initializer_list<std::pair<ConstString, bool>> &names,
-      ConstString *name_of_error = nullptr);
-
   lldb::ValueObjectSP
-  GetChildAtNamePath(const std::vector<std::pair<ConstString, bool>> &names,
+  GetChildAtNamePath(llvm::ArrayRef<std::pair<ConstString, bool>> names,
                      ConstString *name_of_error = nullptr);
 
   virtual lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 381763d..9e6b9da 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -481,21 +481,8 @@
   return child_sp;
 }
 
-ValueObjectSP
-ValueObject::GetChildAtIndexPath(const std::initializer_list<size_t> &idxs,
-                                 size_t *index_of_error) {
-  return GetChildAtIndexPath(std::vector<size_t>(idxs), index_of_error);
-}
-
-ValueObjectSP ValueObject::GetChildAtIndexPath(
-    const std::initializer_list<std::pair<size_t, bool>> &idxs,
-    size_t *index_of_error) {
-  return GetChildAtIndexPath(std::vector<std::pair<size_t, bool>>(idxs),
-                             index_of_error);
-}
-
 lldb::ValueObjectSP
-ValueObject::GetChildAtIndexPath(const std::vector<size_t> &idxs,
+ValueObject::GetChildAtIndexPath(llvm::ArrayRef<size_t> idxs,
                                  size_t *index_of_error) {
   if (idxs.size() == 0)
     return GetSP();
@@ -512,7 +499,7 @@
 }
 
 lldb::ValueObjectSP ValueObject::GetChildAtIndexPath(
-    const std::vector<std::pair<size_t, bool>> &idxs, size_t *index_of_error) {
+  llvm::ArrayRef<std::pair<size_t, bool>> idxs, size_t *index_of_error) {
   if (idxs.size() == 0)
     return GetSP();
   ValueObjectSP root(GetSP());
@@ -528,20 +515,7 @@
 }
 
 lldb::ValueObjectSP
-ValueObject::GetChildAtNamePath(const std::initializer_list<ConstString> &names,
-                                ConstString *name_of_error) {
-  return GetChildAtNamePath(std::vector<ConstString>(names), name_of_error);
-}
-
-lldb::ValueObjectSP ValueObject::GetChildAtNamePath(
-    const std::initializer_list<std::pair<ConstString, bool>> &names,
-    ConstString *name_of_error) {
-  return GetChildAtNamePath(std::vector<std::pair<ConstString, bool>>(names),
-                            name_of_error);
-}
-
-lldb::ValueObjectSP
-ValueObject::GetChildAtNamePath(const std::vector<ConstString> &names,
+ValueObject::GetChildAtNamePath(llvm::ArrayRef<ConstString> names,
                                 ConstString *name_of_error) {
   if (names.size() == 0)
     return GetSP();
@@ -558,7 +532,7 @@
 }
 
 lldb::ValueObjectSP ValueObject::GetChildAtNamePath(
-    const std::vector<std::pair<ConstString, bool>> &names,
+    llvm::ArrayRef<std::pair<ConstString, bool>> names,
     ConstString *name_of_error) {
   if (names.size() == 0)
     return GetSP();
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 72d9967..659a12b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -395,7 +395,8 @@
   if (!D)
     return false;
 
-  ValueObjectSP layout_decider(D->GetChildAtIndexPath({0, 0}));
+  ValueObjectSP layout_decider(
+    D->GetChildAtIndexPath(llvm::ArrayRef<size_t>({0, 0})));
 
   // this child should exist
   if (!layout_decider)