[Lldb-commits] [lldb] r301441 - Use llvm::ArrayRef rather than std::vector/std::initializer lists for some

Lang Hames via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 26 11:15:41 PDT 2017


Author: lhames
Date: Wed Apr 26 13:15:40 2017
New Revision: 301441

URL: http://llvm.org/viewvc/llvm-project?rev=301441&view=rev
Log:
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

Modified:
    lldb/trunk/include/lldb/Core/ValueObject.h
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=301441&r1=301440&r2=301441&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Wed Apr 26 13:15:40 2017
@@ -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 @@ public:
   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,

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=301441&r1=301440&r2=301441&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Wed Apr 26 13:15:40 2017
@@ -481,21 +481,8 @@ ValueObjectSP ValueObject::GetChildAtInd
   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 @@ ValueObject::GetChildAtIndexPath(const s
 }
 
 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::GetChil
 }
 
 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 @@ ValueObject::GetChildAtNamePath(const st
 }
 
 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();

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp?rev=301441&r1=301440&r2=301441&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp Wed Apr 26 13:15:40 2017
@@ -395,7 +395,8 @@ static bool ExtractLibcxxStringInfo(Valu
   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)




More information about the lldb-commits mailing list