[lldb] Take StringRef name in GetChildMemberWithName (NFC)
authorDave Lee <davelee.com@gmail.com>
Sat, 27 May 2023 04:19:10 +0000 (21:19 -0700)
committerDave Lee <davelee.com@gmail.com>
Wed, 31 May 2023 15:08:40 +0000 (08:08 -0700)
`GetChildMemberWithName` does not need a `ConstString`. This change makes the function
take a `StringRef` instead, which alleviates the need for callers to construct a
`ConstString`. I don't expect this change to improve performance, only ergonomics.

This is in support of Alex's effort to replace `ConstString` where appropriate.

There are related `ValueObject` functions that can also be changed, if this is accepted.

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

26 files changed:
lldb/include/lldb/Core/ValueObject.h
lldb/include/lldb/Core/ValueObjectRegister.h
lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
lldb/source/API/SBValue.cpp
lldb/source/Core/ValueObject.cpp
lldb/source/Core/ValueObjectRegister.cpp
lldb/source/Core/ValueObjectSyntheticFilter.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionUtil.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp

index a666d0b..00fdb87 100644 (file)
@@ -487,7 +487,7 @@ public:
   GetChildAtNamePath(llvm::ArrayRef<std::pair<ConstString, bool>> names,
                      ConstString *name_of_error = nullptr);
 
-  virtual lldb::ValueObjectSP GetChildMemberWithName(ConstString name,
+  virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
                                                      bool can_create);
 
   virtual size_t GetIndexOfChildWithName(ConstString name);
index 60c299c..96e8b30 100644 (file)
@@ -52,7 +52,7 @@ public:
   ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
                                   int32_t synthetic_index) override;
 
-  lldb::ValueObjectSP GetChildMemberWithName(ConstString name,
+  lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
                                              bool can_create) override;
 
   size_t GetIndexOfChildWithName(ConstString name) override;
index bdd6c1b..da54ef1 100644 (file)
@@ -53,7 +53,7 @@ public:
 
   lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override;
 
-  lldb::ValueObjectSP GetChildMemberWithName(ConstString name,
+  lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
                                              bool can_create) override;
 
   size_t GetIndexOfChildWithName(ConstString name) override;
index f52041b..573ee3a 100644 (file)
@@ -711,12 +711,11 @@ SBValue::GetChildMemberWithName(const char *name,
   LLDB_INSTRUMENT_VA(this, name, use_dynamic_value);
 
   lldb::ValueObjectSP child_sp;
-  const ConstString str_name(name);
 
   ValueLocker locker;
   lldb::ValueObjectSP value_sp(GetSP(locker));
   if (value_sp) {
-    child_sp = value_sp->GetChildMemberWithName(str_name, true);
+    child_sp = value_sp->GetChildMemberWithName(name, true);
   }
 
   SBValue sb_value;
index 5d26210..48cdcb9 100644 (file)
@@ -466,7 +466,7 @@ size_t ValueObject::GetIndexOfChildWithName(ConstString name) {
                                                    omit_empty_base_classes);
 }
 
-ValueObjectSP ValueObject::GetChildMemberWithName(ConstString name,
+ValueObjectSP ValueObject::GetChildMemberWithName(llvm::StringRef name,
                                                   bool can_create) {
   // We may need to update our value if we are dynamic.
   if (IsPossibleDynamicType())
@@ -483,7 +483,7 @@ ValueObjectSP ValueObject::GetChildMemberWithName(ConstString name,
 
   const size_t num_child_indexes =
       GetCompilerType().GetIndexOfChildMemberWithName(
-          name.GetCString(), omit_empty_base_classes, child_indexes);
+          name.str().data(), omit_empty_base_classes, child_indexes);
   if (num_child_indexes == 0)
     return nullptr;
 
@@ -2714,13 +2714,11 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
     }
 
   } else if (HasSyntheticValue()) {
-    m_deref_valobj =
-        GetSyntheticValue()
-            ->GetChildMemberWithName(ConstString("$$dereference$$"), true)
-            .get();
+    m_deref_valobj = GetSyntheticValue()
+                         ->GetChildMemberWithName("$$dereference$$", true)
+                         .get();
   } else if (IsSynthetic()) {
-    m_deref_valobj =
-        GetChildMemberWithName(ConstString("$$dereference$$"), true).get();
+    m_deref_valobj = GetChildMemberWithName("$$dereference$$", true).get();
   }
 
   if (m_deref_valobj) {
index a0fbf9a..8a807c3 100644 (file)
@@ -128,12 +128,11 @@ ValueObject *ValueObjectRegisterSet::CreateChildAtIndex(
 }
 
 lldb::ValueObjectSP
-ValueObjectRegisterSet::GetChildMemberWithName(ConstString name,
+ValueObjectRegisterSet::GetChildMemberWithName(llvm::StringRef name,
                                                bool can_create) {
   ValueObject *valobj = nullptr;
   if (m_reg_ctx_sp && m_reg_set) {
-    const RegisterInfo *reg_info =
-        m_reg_ctx_sp->GetRegisterInfoByName(name.GetStringRef());
+    const RegisterInfo *reg_info = m_reg_ctx_sp->GetRegisterInfoByName(name);
     if (reg_info != nullptr)
       valobj = new ValueObjectRegister(*this, m_reg_ctx_sp, reg_info);
   }
index bd83d59..315ab2b 100644 (file)
@@ -306,11 +306,11 @@ lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx,
 }
 
 lldb::ValueObjectSP
-ValueObjectSynthetic::GetChildMemberWithName(ConstString name,
+ValueObjectSynthetic::GetChildMemberWithName(llvm::StringRef name,
                                              bool can_create) {
   UpdateValueIfNeeded();
 
-  uint32_t index = GetIndexOfChildWithName(name);
+  uint32_t index = GetIndexOfChildWithName(ConstString(name));
 
   if (index == UINT32_MAX)
     return lldb::ValueObjectSP();
index 9cf70f1..c6d4e68 100644 (file)
@@ -76,8 +76,7 @@ lldb::ValueObjectSP GetCapturedThisValueObject(StackFrame *frame) {
   assert(frame);
 
   if (auto thisValSP = frame->FindVariable(ConstString("this")))
-    if (auto thisThisValSP =
-            thisValSP->GetChildMemberWithName(ConstString("this"), true))
+    if (auto thisThisValSP = thisValSP->GetChildMemberWithName("this", true))
       return thisThisValSP;
 
   return nullptr;
index 9b490e1..a144f5b 100644 (file)
@@ -18,7 +18,7 @@ lldb::ValueObjectSP GetLambdaValueObject(StackFrame *frame) {
   assert(frame);
 
   if (auto this_val_sp = frame->FindVariable(ConstString("this")))
-    if (this_val_sp->GetChildMemberWithName(ConstString("this"), true))
+    if (this_val_sp->GetChildMemberWithName("this", true))
       return this_val_sp;
 
   return nullptr;
index 812a5d7..7ad39e0 100644 (file)
@@ -880,8 +880,7 @@ lldb::addr_t ClangUserExpression::GetCppObjectPointer(
   // We're inside a C++ class method. This could potentially be an unnamed
   // lambda structure. If the lambda captured a "this", that should be
   // the object pointer.
-  if (auto thisChildSP =
-          valobj_sp->GetChildMemberWithName(ConstString("this"), true)) {
+  if (auto thisChildSP = valobj_sp->GetChildMemberWithName("this", true)) {
     valobj_sp = thisChildSP;
   }
 
index 74b3f71..f917de0 100644 (file)
@@ -65,12 +65,10 @@ bool GenericOptionalFrontend::Update() {
   ValueObjectSP engaged_sp;
 
   if (m_stdlib == StdLib::LibCxx)
-    engaged_sp =
-        m_backend.GetChildMemberWithName(ConstString("__engaged_"), true);
+    engaged_sp = m_backend.GetChildMemberWithName("__engaged_", true);
   else if (m_stdlib == StdLib::LibStdcpp)
-    engaged_sp =
-        m_backend.GetChildMemberWithName(ConstString("_M_payload"), true)
-            ->GetChildMemberWithName(ConstString("_M_engaged"), true);
+    engaged_sp = m_backend.GetChildMemberWithName("_M_payload", true)
+                     ->GetChildMemberWithName("_M_engaged", true);
 
   if (!engaged_sp)
     return false;
@@ -94,18 +92,17 @@ ValueObjectSP GenericOptionalFrontend::GetChildAtIndex(size_t _idx) {
     // Currently because it is part of an anonymous union
     // GetChildMemberWithName() does not peer through and find it unless we are
     // at the parent itself. We can obtain the parent through __engaged_.
-    val_sp = m_backend.GetChildMemberWithName(ConstString("__engaged_"), true)
+    val_sp = m_backend.GetChildMemberWithName("__engaged_", true)
                  ->GetParent()
                  ->GetChildAtIndex(0, true)
-                 ->GetChildMemberWithName(ConstString("__val_"), true);
+                 ->GetChildMemberWithName("__val_", true);
   else if (m_stdlib == StdLib::LibStdcpp) {
-    val_sp = m_backend.GetChildMemberWithName(ConstString("_M_payload"), true)
-                 ->GetChildMemberWithName(ConstString("_M_payload"), true);
+    val_sp = m_backend.GetChildMemberWithName("_M_payload", true)
+                 ->GetChildMemberWithName("_M_payload", true);
 
     // In some implementations, _M_value contains the underlying value of an
     // optional, and in other versions, it's in the payload member.
-    ValueObjectSP candidate =
-        val_sp->GetChildMemberWithName(ConstString("_M_value"), true);
+    ValueObjectSP candidate = val_sp->GetChildMemberWithName("_M_value", true);
     if (candidate)
       val_sp = candidate;
   }
index 236a812..12d32c9 100644 (file)
@@ -52,10 +52,10 @@ lldb_private::formatters::GetFirstValueOfLibCXXCompressedPair(
   ValueObjectSP value;
   ValueObjectSP first_child = pair.GetChildAtIndex(0, true);
   if (first_child)
-    value = first_child->GetChildMemberWithName(ConstString("__value_"), true);
+    value = first_child->GetChildMemberWithName("__value_", true);
   if (!value) {
     // pre-r300140 member name
-    value = pair.GetChildMemberWithName(ConstString("__first_"), true);
+    value = pair.GetChildMemberWithName("__first_", true);
   }
   return value;
 }
@@ -67,13 +67,12 @@ lldb_private::formatters::GetSecondValueOfLibCXXCompressedPair(
   if (pair.GetNumChildren() > 1) {
     ValueObjectSP second_child = pair.GetChildAtIndex(1, true);
     if (second_child) {
-      value =
-          second_child->GetChildMemberWithName(ConstString("__value_"), true);
+      value = second_child->GetChildMemberWithName("__value_", true);
     }
   }
   if (!value) {
     // pre-r300140 member name
-    value = pair.GetChildMemberWithName(ConstString("__second_"), true);
+    value = pair.GetChildMemberWithName("__second_", true);
   }
   return value;
 }
@@ -87,7 +86,7 @@ bool lldb_private::formatters::LibcxxOptionalSummaryProvider(
   // An optional either contains a value or not, the member __engaged_ is
   // a bool flag, it is true if the optional has a value and false otherwise.
   ValueObjectSP engaged_sp(
-      valobj_sp->GetChildMemberWithName(ConstString("__engaged_"), true));
+      valobj_sp->GetChildMemberWithName("__engaged_", true));
 
   if (!engaged_sp)
     return false;
@@ -153,8 +152,7 @@ bool lldb_private::formatters::LibcxxSmartPointerSummaryProvider(
   ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
   if (!valobj_sp)
     return false;
-  ValueObjectSP ptr_sp(
-      valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
+  ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("__ptr_", true));
   ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath(
       {ConstString("__cntrl_"), ConstString("__shared_owners_")}));
   ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath(
@@ -197,8 +195,7 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider(
   if (!valobj_sp)
     return false;
 
-  ValueObjectSP ptr_sp(
-      valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
+  ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("__ptr_", true));
   if (!ptr_sp)
     return false;
 
@@ -273,8 +270,6 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() {
   if (!valobj_sp)
     return false;
 
-  static ConstString g_i_("__i_");
-
   // this must be a ValueObject* because it is a child of the ValueObject we
   // are producing children for it if were a ValueObjectSP, we would end up
   // with a loop (iterator -> synthetic -> child -> parent == iterator) and
@@ -303,7 +298,7 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() {
                          nullptr)
                      .get();
     if (m_pair_ptr) {
-      auto __i_(valobj_sp->GetChildMemberWithName(g_i_, true));
+      auto __i_(valobj_sp->GetChildMemberWithName("__i_", true));
       if (!__i_) {
         m_pair_ptr = nullptr;
         return false;
@@ -462,8 +457,7 @@ bool lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::
           .get();
 
   if (m_iter_ptr) {
-    auto iter_child(
-        valobj_sp->GetChildMemberWithName(ConstString("__i_"), true));
+    auto iter_child(valobj_sp->GetChildMemberWithName("__i_", true));
     if (!iter_child) {
       m_iter_ptr = nullptr;
       return false;
@@ -610,11 +604,10 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex(
     return lldb::ValueObjectSP();
 
   if (idx == 0)
-    return valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true);
+    return valobj_sp->GetChildMemberWithName("__ptr_", true);
 
   if (idx == 1) {
-    if (auto ptr_sp =
-            valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true)) {
+    if (auto ptr_sp = valobj_sp->GetChildMemberWithName("__ptr_", true)) {
       Status status;
       auto value_sp = ptr_sp->Dereference(status);
       if (status.Success()) {
@@ -640,7 +633,7 @@ bool lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() {
     return false;
 
   lldb::ValueObjectSP cntrl_sp(
-      valobj_sp->GetChildMemberWithName(ConstString("__cntrl_"), true));
+      valobj_sp->GetChildMemberWithName("__cntrl_", true));
 
   m_cntrl = cntrl_sp.get(); // need to store the raw pointer to avoid a circular
                             // dependency
@@ -723,8 +716,7 @@ bool lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() {
   if (!valobj_sp)
     return false;
 
-  ValueObjectSP ptr_sp(
-      valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
+  ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("__ptr_", true));
   if (!ptr_sp)
     return false;
 
@@ -780,7 +772,7 @@ enum class StringLayout { CSD, DSC };
 static std::optional<std::pair<uint64_t, ValueObjectSP>>
 ExtractLibcxxStringInfo(ValueObject &valobj) {
   ValueObjectSP valobj_r_sp =
-      valobj.GetChildMemberWithName(ConstString("__r_"), /*can_create=*/true);
+      valobj.GetChildMemberWithName("__r_", /*can_create=*/true);
   if (!valobj_r_sp || !valobj_r_sp->GetError().Success())
     return {};
 
@@ -791,12 +783,12 @@ ExtractLibcxxStringInfo(ValueObject &valobj) {
   if (!valobj_r_base_sp)
     return {};
 
-  ValueObjectSP valobj_rep_sp = valobj_r_base_sp->GetChildMemberWithName(
-      ConstString("__value_"), /*can_create=*/true);
+  ValueObjectSP valobj_rep_sp =
+      valobj_r_base_sp->GetChildMemberWithName("__value_", /*can_create=*/true);
   if (!valobj_rep_sp)
     return {};
 
-  ValueObjectSP l = valobj_rep_sp->GetChildMemberWithName(ConstString("__l"),
+  ValueObjectSP l = valobj_rep_sp->GetChildMemberWithName("__l",
                                                           /*can_create=*/true);
   if (!l)
     return {};
@@ -812,13 +804,12 @@ ExtractLibcxxStringInfo(ValueObject &valobj) {
   uint64_t size;
   uint64_t size_mode_value = 0;
 
-  ValueObjectSP short_sp = valobj_rep_sp->GetChildMemberWithName(
-      ConstString("__s"), /*can_create=*/true);
+  ValueObjectSP short_sp =
+      valobj_rep_sp->GetChildMemberWithName("__s", /*can_create=*/true);
   if (!short_sp)
     return {};
 
-  ValueObjectSP is_long =
-      short_sp->GetChildMemberWithName(ConstString("__is_long_"), true);
+  ValueObjectSP is_long = short_sp->GetChildMemberWithName("__is_long_", true);
   ValueObjectSP size_sp =
       short_sp->GetChildAtNamePath({ConstString("__size_")});
   if (!size_sp)
@@ -837,7 +828,7 @@ ExtractLibcxxStringInfo(ValueObject &valobj) {
 
   if (short_mode) {
     ValueObjectSP location_sp =
-        short_sp->GetChildMemberWithName(ConstString("__data_"), true);
+        short_sp->GetChildMemberWithName("__data_", true);
     if (using_bitmasks)
       size = (layout == StringLayout::DSC) ? size_mode_value
                                            : ((size_mode_value >> 1) % 256);
@@ -857,11 +848,11 @@ ExtractLibcxxStringInfo(ValueObject &valobj) {
 
   // we can use the layout_decider object as the data pointer
   ValueObjectSP location_sp =
-      l->GetChildMemberWithName(ConstString("__data_"), /*can_create=*/true);
+      l->GetChildMemberWithName("__data_", /*can_create=*/true);
   ValueObjectSP size_vo =
-      l->GetChildMemberWithName(ConstString("__size_"), /*can_create=*/true);
+      l->GetChildMemberWithName("__size_", /*can_create=*/true);
   ValueObjectSP capacity_vo =
-      l->GetChildMemberWithName(ConstString("__cap_"), /*can_create=*/true);
+      l->GetChildMemberWithName("__cap_", /*can_create=*/true);
   if (!size_vo || !location_sp || !capacity_vo)
     return {};
   size = size_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
index 8b30e3f..2baacc4 100644 (file)
@@ -55,13 +55,12 @@ lldb_private::formatters::GetLibCxxAtomicValue(ValueObject &valobj) {
   if (!non_sythetic)
     return {};
 
-  ValueObjectSP member__a_ =
-      non_sythetic->GetChildMemberWithName(ConstString("__a_"), true);
+  ValueObjectSP member__a_ = non_sythetic->GetChildMemberWithName("__a_", true);
   if (!member__a_)
     return {};
 
   ValueObjectSP member__a_value =
-      member__a_->GetChildMemberWithName(ConstString("__a_value"), true);
+      member__a_->GetChildMemberWithName("__a_value", true);
   if (!member__a_value)
     return member__a_;
 
index fbea4ec..379f81c 100644 (file)
@@ -61,9 +61,8 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
 
 size_t lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
     CalculateNumChildren() {
-  static ConstString g_size_("__size_");
   m_num_elements = 0;
-  ValueObjectSP size_sp(m_backend.GetChildMemberWithName(g_size_, true));
+  ValueObjectSP size_sp(m_backend.GetChildMemberWithName("__size_", true));
   if (size_sp)
     m_num_elements = size_sp->GetValueAsUnsigned(0);
   return m_num_elements;
@@ -85,8 +84,6 @@ lldb::ValueObjectSP lldb_private::formatters::
 
 bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
     Update() {
-  static ConstString g_begin_("__begin_");
-
   m_start = nullptr;
   m_num_elements = 0;
   m_element_type = m_backend.GetCompilerType().GetTypeTemplateArgument(0);
@@ -96,7 +93,7 @@ bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
   if (std::optional<uint64_t> size = m_element_type.GetByteSize(nullptr)) {
     m_element_size = *size;
     // Store raw pointers or end up with a circular dependency.
-    m_start = m_backend.GetChildMemberWithName(g_begin_, true).get();
+    m_start = m_backend.GetChildMemberWithName("__begin_", true).get();
   }
 
   return false;
index 3ae26a3..d50f869 100644 (file)
@@ -32,19 +32,15 @@ public:
       : m_entry_sp(entry ? entry->GetSP() : ValueObjectSP()) {}
 
   ListEntry next() {
-    static ConstString g_next("__next_");
-
     if (!m_entry_sp)
       return ListEntry();
-    return ListEntry(m_entry_sp->GetChildMemberWithName(g_next, true));
+    return ListEntry(m_entry_sp->GetChildMemberWithName("__next_", true));
   }
 
   ListEntry prev() {
-    static ConstString g_prev("__prev_");
-
     if (!m_entry_sp)
       return ListEntry();
-    return ListEntry(m_entry_sp->GetChildMemberWithName(g_prev, true));
+    return ListEntry(m_entry_sp->GetChildMemberWithName("__prev_", true));
   }
 
   uint64_t value() const {
@@ -297,13 +293,13 @@ bool ForwardListFrontEnd::Update() {
     return false;
 
   ValueObjectSP impl_sp(
-      m_backend.GetChildMemberWithName(ConstString("__before_begin_"), true));
+      m_backend.GetChildMemberWithName("__before_begin_", true));
   if (!impl_sp)
     return false;
   impl_sp = GetFirstValueOfLibCXXCompressedPair(*impl_sp);
   if (!impl_sp)
     return false;
-  m_head = impl_sp->GetChildMemberWithName(ConstString("__next_"), true).get();
+  m_head = impl_sp->GetChildMemberWithName("__next_", true).get();
   return false;
 }
 
@@ -319,7 +315,7 @@ size_t ListFrontEnd::CalculateNumChildren() {
   if (!m_head || !m_tail || m_node_address == 0)
     return 0;
   ValueObjectSP size_alloc(
-      m_backend.GetChildMemberWithName(ConstString("__size_alloc_"), true));
+      m_backend.GetChildMemberWithName("__size_alloc_", true));
   if (size_alloc) {
     ValueObjectSP value = GetFirstValueOfLibCXXCompressedPair(*size_alloc);
     if (value) {
@@ -412,12 +408,11 @@ bool ListFrontEnd::Update() {
   m_node_address = backend_addr->GetValueAsUnsigned(0);
   if (!m_node_address || m_node_address == LLDB_INVALID_ADDRESS)
     return false;
-  ValueObjectSP impl_sp(
-      m_backend.GetChildMemberWithName(ConstString("__end_"), true));
+  ValueObjectSP impl_sp(m_backend.GetChildMemberWithName("__end_", true));
   if (!impl_sp)
     return false;
-  m_head = impl_sp->GetChildMemberWithName(ConstString("__next_"), true).get();
-  m_tail = impl_sp->GetChildMemberWithName(ConstString("__prev_"), true).get();
+  m_head = impl_sp->GetChildMemberWithName("__next_", true).get();
+  m_tail = impl_sp->GetChildMemberWithName("__prev_", true).get();
   return false;
 }
 
index 21dbd64..6a29abe 100644 (file)
@@ -211,27 +211,23 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
 
 size_t lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
     CalculateNumChildren() {
-  static ConstString g_pair3_("__pair3_");
-  static ConstString g_first_("__first_");
-  static ConstString g_value_("__value_");
-
   if (m_count != UINT32_MAX)
     return m_count;
   if (m_tree == nullptr)
     return 0;
-  ValueObjectSP m_item(m_tree->GetChildMemberWithName(g_pair3_, true));
+  ValueObjectSP m_item(m_tree->GetChildMemberWithName("__pair3_", true));
   if (!m_item)
     return 0;
 
   switch (m_item->GetCompilerType().GetNumDirectBaseClasses()) {
   case 1:
     // Assume a pre llvm r300140 __compressed_pair implementation:
-    m_item = m_item->GetChildMemberWithName(g_first_, true);
+    m_item = m_item->GetChildMemberWithName("__first_", true);
     break;
   case 2: {
     // Assume a post llvm r300140 __compressed_pair implementation:
     ValueObjectSP first_elem_parent = m_item->GetChildAtIndex(0, true);
-    m_item = first_elem_parent->GetChildMemberWithName(g_value_, true);
+    m_item = first_elem_parent->GetChildMemberWithName("__value_", true);
     break;
   }
   default:
@@ -245,7 +241,6 @@ size_t lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
 }
 
 bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() {
-  static ConstString g_value_("__value_");
   static ConstString g_tree_("__tree_");
   static ConstString g_pair3("__pair3_");
 
@@ -257,7 +252,7 @@ bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetDataType() {
   deref = m_root_node->Dereference(error);
   if (!deref || error.Fail())
     return false;
-  deref = deref->GetChildMemberWithName(g_value_, true);
+  deref = deref->GetChildMemberWithName("__value_", true);
   if (deref) {
     m_element_type = deref->GetCompilerType();
     return true;
@@ -329,7 +324,6 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex(
     size_t idx) {
   static ConstString g_cc_("__cc_"), g_cc("__cc");
   static ConstString g_nc("__nc");
-  static ConstString g_value_("__value_");
 
   if (idx >= CalculateNumChildren())
     return lldb::ValueObjectSP();
@@ -364,7 +358,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex(
         return lldb::ValueObjectSP();
       }
       GetValueOffset(iterated_sp);
-      auto child_sp = iterated_sp->GetChildMemberWithName(g_value_, true);
+      auto child_sp = iterated_sp->GetChildMemberWithName("__value_", true);
       if (child_sp)
         iterated_sp = child_sp;
       else
@@ -425,15 +419,13 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex(
 }
 
 bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::Update() {
-  static ConstString g_tree_("__tree_");
-  static ConstString g_begin_node_("__begin_node_");
   m_count = UINT32_MAX;
   m_tree = m_root_node = nullptr;
   m_iterators.clear();
-  m_tree = m_backend.GetChildMemberWithName(g_tree_, true).get();
+  m_tree = m_backend.GetChildMemberWithName("__tree_", true).get();
   if (!m_tree)
     return false;
-  m_root_node = m_tree->GetChildMemberWithName(g_begin_node_, true).get();
+  m_root_node = m_tree->GetChildMemberWithName("__begin_node_", true).get();
   return false;
 }
 
index 616ffdc..2c601b5 100644 (file)
@@ -49,7 +49,7 @@ private:
 
 bool QueueFrontEnd::Update() {
   m_container_sp = nullptr;
-  ValueObjectSP c_sp = m_backend.GetChildMemberWithName(ConstString("c"), true);
+  ValueObjectSP c_sp = m_backend.GetChildMemberWithName("c", true);
   if (!c_sp)
     return false;
   m_container_sp = c_sp->GetSyntheticValue().get();
index a113fe9..ada0328 100644 (file)
@@ -45,10 +45,10 @@ bool TupleFrontEnd::Update() {
   m_base = nullptr;
 
   ValueObjectSP base_sp;
-  base_sp = m_backend.GetChildMemberWithName(ConstString("__base_"), true);
+  base_sp = m_backend.GetChildMemberWithName("__base_", true);
   if (!base_sp) {
     // Pre r304382 name of the base element.
-    base_sp = m_backend.GetChildMemberWithName(ConstString("base_"), true);
+    base_sp = m_backend.GetChildMemberWithName("base_", true);
   }
   if (!base_sp)
     return false;
index cba1078..d681b70 100644 (file)
@@ -108,10 +108,8 @@ lldb::ValueObjectSP lldb_private::formatters::
     if (!node_sp || error.Fail())
       return lldb::ValueObjectSP();
 
-    ValueObjectSP value_sp =
-        node_sp->GetChildMemberWithName(ConstString("__value_"), true);
-    ValueObjectSP hash_sp =
-        node_sp->GetChildMemberWithName(ConstString("__hash_"), true);
+    ValueObjectSP value_sp = node_sp->GetChildMemberWithName("__value_", true);
+    ValueObjectSP hash_sp = node_sp->GetChildMemberWithName("__hash_", true);
     if (!hash_sp || !value_sp) {
       if (!m_element_type) {
         auto p1_sp = m_backend.GetChildAtNamePath({ConstString("__table_"),
@@ -123,15 +121,13 @@ lldb::ValueObjectSP lldb_private::formatters::
         switch (p1_sp->GetCompilerType().GetNumDirectBaseClasses()) {
         case 1:
           // Assume a pre llvm r300140 __compressed_pair implementation:
-          first_sp = p1_sp->GetChildMemberWithName(ConstString("__first_"),
-                                                   true);
+          first_sp = p1_sp->GetChildMemberWithName("__first_", true);
           break;
         case 2: {
           // Assume a post llvm r300140 __compressed_pair implementation:
           ValueObjectSP first_elem_parent_sp =
             p1_sp->GetChildAtIndex(0, true);
-          first_sp = p1_sp->GetChildMemberWithName(ConstString("__value_"),
-                                                   true);
+          first_sp = p1_sp->GetChildMemberWithName("__value_", true);
           break;
         }
         default:
@@ -163,15 +159,14 @@ lldb::ValueObjectSP lldb_private::formatters::
       if (!m_node_type)
         return nullptr;
       node_sp = node_sp->Cast(m_node_type);
-      value_sp = node_sp->GetChildMemberWithName(ConstString("__value_"), true);
-      hash_sp = node_sp->GetChildMemberWithName(ConstString("__hash_"), true);
+      value_sp = node_sp->GetChildMemberWithName("__value_", true);
+      hash_sp = node_sp->GetChildMemberWithName("__hash_", true);
       if (!value_sp || !hash_sp)
         return nullptr;
     }
     m_elements_cache.push_back(
         {value_sp.get(), hash_sp->GetValueAsUnsigned(0)});
-    m_next_element =
-        node_sp->GetChildMemberWithName(ConstString("__next_"), true).get();
+    m_next_element = node_sp->GetChildMemberWithName("__next_", true).get();
     if (!m_next_element || m_next_element->GetValueAsUnsigned(0) == 0)
       m_next_element = nullptr;
   }
@@ -198,28 +193,25 @@ bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
   m_num_elements = 0;
   m_next_element = nullptr;
   m_elements_cache.clear();
-  ValueObjectSP table_sp =
-      m_backend.GetChildMemberWithName(ConstString("__table_"), true);
+  ValueObjectSP table_sp = m_backend.GetChildMemberWithName("__table_", true);
   if (!table_sp)
     return false;
 
-  ValueObjectSP p2_sp = table_sp->GetChildMemberWithName(
-    ConstString("__p2_"), true);
+  ValueObjectSP p2_sp = table_sp->GetChildMemberWithName("__p2_", true);
   ValueObjectSP num_elements_sp = nullptr;
   llvm::SmallVector<ConstString, 3> next_path;
   switch (p2_sp->GetCompilerType().GetNumDirectBaseClasses()) {
   case 1:
     // Assume a pre llvm r300140 __compressed_pair implementation:
-    num_elements_sp = p2_sp->GetChildMemberWithName(
-      ConstString("__first_"), true);
+    num_elements_sp = p2_sp->GetChildMemberWithName("__first_", true);
     next_path.append({ConstString("__p1_"), ConstString("__first_"),
                       ConstString("__next_")});
     break;
   case 2: {
     // Assume a post llvm r300140 __compressed_pair implementation:
     ValueObjectSP first_elem_parent = p2_sp->GetChildAtIndex(0, true);
-    num_elements_sp = first_elem_parent->GetChildMemberWithName(
-      ConstString("__value_"), true);
+    num_elements_sp =
+        first_elem_parent->GetChildMemberWithName("__value_", true);
     next_path.append({ConstString("__p1_"), ConstString("__value_"),
                       ConstString("__next_")});
     break;
index 4e54e7b..f66dc89 100644 (file)
@@ -83,8 +83,7 @@ uint64_t VariantNposValue(uint64_t index_byte_size) {
 
 LibcxxVariantIndexValidity
 LibcxxVariantGetIndexValidity(ValueObjectSP &impl_sp) {
-  ValueObjectSP index_sp(
-      impl_sp->GetChildMemberWithName(ConstString("__index"), true));
+  ValueObjectSP index_sp(impl_sp->GetChildMemberWithName("__index", true));
 
   if (!index_sp)
     return LibcxxVariantIndexValidity::Invalid;
@@ -112,8 +111,7 @@ LibcxxVariantGetIndexValidity(ValueObjectSP &impl_sp) {
 }
 
 std::optional<uint64_t> LibcxxVariantIndexValue(ValueObjectSP &impl_sp) {
-  ValueObjectSP index_sp(
-      impl_sp->GetChildMemberWithName(ConstString("__index"), true));
+  ValueObjectSP index_sp(impl_sp->GetChildMemberWithName("__index", true));
 
   if (!index_sp)
     return {};
@@ -122,8 +120,7 @@ std::optional<uint64_t> LibcxxVariantIndexValue(ValueObjectSP &impl_sp) {
 }
 
 ValueObjectSP LibcxxVariantGetNthHead(ValueObjectSP &impl_sp, uint64_t index) {
-  ValueObjectSP data_sp(
-      impl_sp->GetChildMemberWithName(ConstString("__data"), true));
+  ValueObjectSP data_sp(impl_sp->GetChildMemberWithName("__data", true));
 
   if (!data_sp)
     return ValueObjectSP{};
@@ -131,7 +128,7 @@ ValueObjectSP LibcxxVariantGetNthHead(ValueObjectSP &impl_sp, uint64_t index) {
   ValueObjectSP current_level = data_sp;
   for (uint64_t n = index; n != 0; --n) {
     ValueObjectSP tail_sp(
-        current_level->GetChildMemberWithName(ConstString("__tail"), true));
+        current_level->GetChildMemberWithName("__tail", true));
 
     if (!tail_sp)
       return ValueObjectSP{};
@@ -139,7 +136,7 @@ ValueObjectSP LibcxxVariantGetNthHead(ValueObjectSP &impl_sp, uint64_t index) {
     current_level = tail_sp;
   }
 
-  return current_level->GetChildMemberWithName(ConstString("__head"), true);
+  return current_level->GetChildMemberWithName("__head", true);
 }
 } // namespace
 
@@ -268,8 +265,7 @@ ValueObjectSP VariantFrontEnd::GetChildAtIndex(size_t idx) {
   if (!template_type)
     return {};
 
-  ValueObjectSP head_value(
-      nth_head->GetChildMemberWithName(ConstString("__value"), true));
+  ValueObjectSP head_value(nth_head->GetChildMemberWithName("__value", true));
 
   if (!head_value)
     return {};
index 218ff9c..28f54a3 100644 (file)
@@ -119,22 +119,22 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::GetChildAtIndex(
 bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() {
   m_start = m_finish = nullptr;
   ValueObjectSP data_type_finder_sp(
-      m_backend.GetChildMemberWithName(ConstString("__end_cap_"), true));
+      m_backend.GetChildMemberWithName("__end_cap_", true));
   if (!data_type_finder_sp)
     return false;
 
   switch (data_type_finder_sp->GetCompilerType().GetNumDirectBaseClasses()) {
   case 1:
     // Assume a pre llvm r300140 __compressed_pair implementation:
-    data_type_finder_sp = data_type_finder_sp->GetChildMemberWithName(
-      ConstString("__first_"), true);
+    data_type_finder_sp =
+        data_type_finder_sp->GetChildMemberWithName("__first_", true);
     break;
   case 2: {
     // Assume a post llvm r300140 __compressed_pair implementation:
     ValueObjectSP first_elem_parent_sp =
       data_type_finder_sp->GetChildAtIndex(0, true);
-    data_type_finder_sp = first_elem_parent_sp->GetChildMemberWithName(
-      ConstString("__value_"), true);
+    data_type_finder_sp =
+        first_elem_parent_sp->GetChildMemberWithName("__value_", true);
     break;
   }
   default:
@@ -149,10 +149,8 @@ bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() {
 
     if (m_element_size > 0) {
       // store raw pointers or end up with a circular dependency
-      m_start =
-          m_backend.GetChildMemberWithName(ConstString("__begin_"), true).get();
-      m_finish =
-          m_backend.GetChildMemberWithName(ConstString("__end_"), true).get();
+      m_start = m_backend.GetChildMemberWithName("__begin_", true).get();
+      m_finish = m_backend.GetChildMemberWithName("__end_", true).get();
     }
   }
   return false;
@@ -249,15 +247,13 @@ bool lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update() {
   if (!valobj_sp)
     return false;
   m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
-  ValueObjectSP size_sp(
-      valobj_sp->GetChildMemberWithName(ConstString("__size_"), true));
+  ValueObjectSP size_sp(valobj_sp->GetChildMemberWithName("__size_", true));
   if (!size_sp)
     return false;
   m_count = size_sp->GetValueAsUnsigned(0);
   if (!m_count)
     return true;
-  ValueObjectSP begin_sp(
-      valobj_sp->GetChildMemberWithName(ConstString("__begin_"), true));
+  ValueObjectSP begin_sp(valobj_sp->GetChildMemberWithName("__begin_", true));
   if (!begin_sp) {
     m_count = 0;
     return false;
index bd129d2..76b934c 100644 (file)
@@ -110,8 +110,7 @@ bool LibstdcppMapIteratorSyntheticFrontEnd::Update() {
     return false;
   m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
 
-  ValueObjectSP _M_node_sp(
-      valobj_sp->GetChildMemberWithName(ConstString("_M_node"), true));
+  ValueObjectSP _M_node_sp(valobj_sp->GetChildMemberWithName("_M_node", true));
   if (!_M_node_sp)
     return false;
 
@@ -393,7 +392,7 @@ bool LibStdcppSharedPtrSyntheticFrontEnd::Update() {
   if (!valobj_sp)
     return false;
 
-  auto ptr_obj_sp = valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true);
+  auto ptr_obj_sp = valobj_sp->GetChildMemberWithName("_M_ptr", true);
   if (!ptr_obj_sp)
     return false;
 
@@ -434,8 +433,7 @@ bool lldb_private::formatters::LibStdcppSmartPointerSummaryProvider(
   if (!valobj_sp)
     return false;
 
-  ValueObjectSP ptr_sp(
-      valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true));
+  ValueObjectSP ptr_sp(valobj_sp->GetChildMemberWithName("_M_ptr", true));
   if (!ptr_sp)
     return false;
 
index 7ba59ff..ed7cbb5 100644 (file)
@@ -73,7 +73,7 @@ bool LibStdcppTupleSyntheticFrontEnd::Update() {
         next_child_sp = child_sp;
       } else if (name_str.startswith("std::_Head_base<")) {
         ValueObjectSP value_sp =
-            child_sp->GetChildMemberWithName(ConstString("_M_head_impl"), true);
+            child_sp->GetChildMemberWithName("_M_head_impl", true);
         if (value_sp) {
           StreamString name;
           name.Printf("[%zd]", m_members.size());
index 79e864a..fae3e24 100644 (file)
@@ -69,13 +69,12 @@ ValueObjectSP LibStdcppUniquePtrSyntheticFrontEnd::GetTuple() {
   if (!valobj_sp)
     return nullptr;
 
-  ValueObjectSP obj_child_sp =
-      valobj_sp->GetChildMemberWithName(ConstString("_M_t"), true);
+  ValueObjectSP obj_child_sp = valobj_sp->GetChildMemberWithName("_M_t", true);
   if (!obj_child_sp)
       return nullptr;
 
   ValueObjectSP obj_subchild_sp =
-      obj_child_sp->GetChildMemberWithName(ConstString("_M_t"), true);
+      obj_child_sp->GetChildMemberWithName("_M_t", true);
 
   // if there is a _M_t subchild, the tuple is found in the obj_subchild_sp
   // (for libstdc++ 6.0.23).
index 0028a51..10ab735 100644 (file)
@@ -138,12 +138,11 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo(
   //    we will obtain the name from this pointer.
   // 5) a free function. A pointer to the function will stored after the vtable
   //    we will obtain the name from this pointer.
-  ValueObjectSP member_f_(
-      valobj_sp->GetChildMemberWithName(ConstString("__f_"), true));
+  ValueObjectSP member_f_(valobj_sp->GetChildMemberWithName("__f_", true));
 
   if (member_f_) {
     ValueObjectSP sub_member_f_(
-       member_f_->GetChildMemberWithName(ConstString("__f_"), true));
+        member_f_->GetChildMemberWithName("__f_", true));
 
     if (sub_member_f_)
         member_f_ = sub_member_f_;
index 27881f0..6969305 100644 (file)
@@ -514,7 +514,7 @@ static ThreadSP FailExceptionParsing(llvm::StringRef msg) {
 ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
     lldb::ValueObjectSP exception_sp) {
   ValueObjectSP reserved_dict =
-      exception_sp->GetChildMemberWithName(ConstString("reserved"), true);
+      exception_sp->GetChildMemberWithName("reserved", true);
   if (!reserved_dict)
     return FailExceptionParsing("Failed to get 'reserved' member.");
 
@@ -567,18 +567,15 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
 
   if (!return_addresses)
     return FailExceptionParsing("Failed to get return addresses.");
-  auto frames_value =
-      return_addresses->GetChildMemberWithName(ConstString("_frames"), true);
+  auto frames_value = return_addresses->GetChildMemberWithName("_frames", true);
   if (!frames_value)
     return FailExceptionParsing("Failed to get frames_value.");
   addr_t frames_addr = frames_value->GetValueAsUnsigned(0);
-  auto count_value =
-      return_addresses->GetChildMemberWithName(ConstString("_cnt"), true);
+  auto count_value = return_addresses->GetChildMemberWithName("_cnt", true);
   if (!count_value)
     return FailExceptionParsing("Failed to get count_value.");
   size_t count = count_value->GetValueAsUnsigned(0);
-  auto ignore_value =
-      return_addresses->GetChildMemberWithName(ConstString("_ignore"), true);
+  auto ignore_value = return_addresses->GetChildMemberWithName("_ignore", true);
   if (!ignore_value)
     return FailExceptionParsing("Failed to get ignore_value.");
   size_t ignore = ignore_value->GetValueAsUnsigned(0);