Remove duplicated code for synthetic array members.
authorBruce Mitchener <bruce.mitchener@gmail.com>
Thu, 26 Feb 2015 23:55:39 +0000 (23:55 +0000)
committerBruce Mitchener <bruce.mitchener@gmail.com>
Thu, 26 Feb 2015 23:55:39 +0000 (23:55 +0000)
Summary:
The code for GetSyntheticArrayMemberFromPointer and
GetSyntheticArrayMemberFromArray was identical, so just collapse the
the methods into one.

Reviewers: granata.enrico, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D7911

llvm-svn: 230708

lldb/include/lldb/Core/ValueObject.h
lldb/source/API/SBValue.cpp
lldb/source/Core/ValueObject.cpp
lldb/source/DataFormatters/NSIndexPath.cpp
lldb/source/Target/StackFrame.cpp

index a29b67d..d59ee30 100644 (file)
@@ -679,12 +679,6 @@ public:
     GetSyntheticArrayMember (size_t index, bool can_create);
 
     lldb::ValueObjectSP
-    GetSyntheticArrayMemberFromPointer (size_t index, bool can_create);
-    
-    lldb::ValueObjectSP
-    GetSyntheticArrayMemberFromArray (size_t index, bool can_create);
-    
-    lldb::ValueObjectSP
     GetSyntheticBitFieldChild (uint32_t from, uint32_t to, bool can_create);
 
     lldb::ValueObjectSP
index e383f4c..1b29f6c 100644 (file)
@@ -969,14 +969,7 @@ SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool
         child_sp = value_sp->GetChildAtIndex (idx, can_create);
         if (can_create_synthetic && !child_sp)
         {
-            if (value_sp->IsPointerType())
-            {
-                child_sp = value_sp->GetSyntheticArrayMemberFromPointer(idx, can_create);
-            }
-            else if (value_sp->IsArrayType())
-            {
-                child_sp = value_sp->GetSyntheticArrayMemberFromArray(idx, can_create);
-            }
+            child_sp = value_sp->GetSyntheticArrayMember(idx, can_create);
         }
     }
 
index 231f497..f1af96a 100644 (file)
@@ -2090,52 +2090,6 @@ ValueObject::IsObjCNil ()
     return canReadValue && isZero;
 }
 
-ValueObjectSP
-ValueObject::GetSyntheticArrayMember (size_t index, bool can_create)
-{
-    const uint32_t type_info = GetTypeInfo ();
-    if (type_info & eTypeIsArray)
-        return GetSyntheticArrayMemberFromArray(index, can_create);
-
-    if (type_info & eTypeIsPointer)
-        return GetSyntheticArrayMemberFromPointer(index, can_create);
-    
-    return ValueObjectSP();
-    
-}
-
-ValueObjectSP
-ValueObject::GetSyntheticArrayMemberFromPointer (size_t index, bool can_create)
-{
-    ValueObjectSP synthetic_child_sp;
-    if (IsPointerType ())
-    {
-        char index_str[64];
-        snprintf(index_str, sizeof(index_str), "[%" PRIu64 "]", (uint64_t)index);
-        ConstString index_const_str(index_str);
-        // Check if we have already created a synthetic array member in this
-        // valid object. If we have we will re-use it.
-        synthetic_child_sp = GetSyntheticChild (index_const_str);
-        if (!synthetic_child_sp)
-        {
-            ValueObject *synthetic_child;
-            // We haven't made a synthetic array member for INDEX yet, so
-            // lets make one and cache it for any future reference.
-            synthetic_child = CreateChildAtIndex(0, true, index);
-
-            // Cache the value if we got one back...
-            if (synthetic_child)
-            {
-                AddSyntheticChild(index_const_str, synthetic_child);
-                synthetic_child_sp = synthetic_child->GetSP();
-                synthetic_child_sp->SetName(ConstString(index_str));
-                synthetic_child_sp->m_is_array_item_for_pointer = true;
-            }
-        }
-    }
-    return synthetic_child_sp;
-}
-
 // This allows you to create an array member using and index
 // that doesn't not fall in the normal bounds of the array.
 // Many times structure can be defined as:
@@ -2148,10 +2102,10 @@ ValueObject::GetSyntheticArrayMemberFromPointer (size_t index, bool can_create)
 // there are more items in "item_array".
 
 ValueObjectSP
-ValueObject::GetSyntheticArrayMemberFromArray (size_t index, bool can_create)
+ValueObject::GetSyntheticArrayMember (size_t index, bool can_create)
 {
     ValueObjectSP synthetic_child_sp;
-    if (IsArrayType ())
+    if (IsPointerType () || IsArrayType())
     {
         char index_str[64];
         snprintf(index_str, sizeof(index_str), "[%" PRIu64 "]", (uint64_t)index);
@@ -2165,7 +2119,7 @@ ValueObject::GetSyntheticArrayMemberFromArray (size_t index, bool can_create)
             // We haven't made a synthetic array member for INDEX yet, so
             // lets make one and cache it for any future reference.
             synthetic_child = CreateChildAtIndex(0, true, index);
-            
+
             // Cache the value if we got one back...
             if (synthetic_child)
             {
@@ -3024,7 +2978,7 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
                     {
                         ValueObjectSP child_valobj_sp = root->GetChildAtIndex(index, true);
                         if (!child_valobj_sp)
-                            child_valobj_sp = root->GetSyntheticArrayMemberFromArray(index, true);
+                            child_valobj_sp = root->GetSyntheticArrayMember(index, true);
                         if (!child_valobj_sp)
                             if (root->HasSyntheticValue() && root->GetSyntheticValue()->GetNumChildren() > index)
                                 child_valobj_sp = root->GetSyntheticValue()->GetChildAtIndex(index, true);
@@ -3073,7 +3027,7 @@ ValueObject::GetValueForExpressionPath_Impl(const char* expression_cstr,
                                 root = root->GetSyntheticValue()->GetChildAtIndex(index, true);
                             }
                             else
-                                root = root->GetSyntheticArrayMemberFromPointer(index, true);
+                                root = root->GetSyntheticArrayMember(index, true);
                             if (!root.get())
                             {
                                 *first_unparsed = expression_cstr;
@@ -3416,7 +3370,7 @@ ValueObject::ExpandArraySliceExpression(const char* expression_cstr,
                         }
                         else
                         {
-                            root = root->GetSyntheticArrayMemberFromPointer(index, true);
+                            root = root->GetSyntheticArrayMember(index, true);
                             if (!root.get())
                             {
                                 *first_unparsed = expression_cstr;
index ee9583e..6932211 100644 (file)
@@ -278,7 +278,7 @@ protected:
            {
                if (m_indexes)
                {
-                   ValueObjectSP index_sp(m_indexes->GetSyntheticArrayMemberFromPointer(idx, true));
+                   ValueObjectSP index_sp(m_indexes->GetSyntheticArrayMember(idx, true));
                    return index_sp;
                }
                return nullptr;
index 9a610a5..d6f2dfd 100644 (file)
@@ -920,7 +920,7 @@ StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr,
                                     }
                                     else
                                     {
-                                        child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true);
+                                        child_valobj_sp = valobj_sp->GetSyntheticArrayMember (child_index, true);
                                         if (!child_valobj_sp)
                                         {
                                             valobj_sp->GetExpressionPath (var_expr_path_strm, false);