Hi granata.enrico, clayborg,

The code for GetSyntheticArrayMemberFromPointer and
GetSyntheticArrayMemberFromArray was identical, so just collapse the
the methods into one.

http://reviews.llvm.org/D7911

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

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: include/lldb/Core/ValueObject.h
===================================================================
--- include/lldb/Core/ValueObject.h
+++ include/lldb/Core/ValueObject.h
@@ -679,12 +679,6 @@
     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: source/API/SBValue.cpp
===================================================================
--- source/API/SBValue.cpp
+++ source/API/SBValue.cpp
@@ -969,14 +969,7 @@
         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: source/Core/ValueObject.cpp
===================================================================
--- source/Core/ValueObject.cpp
+++ source/Core/ValueObject.cpp
@@ -2090,52 +2090,6 @@
     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 @@
 // 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 @@
             // 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 @@
                     {
                         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 @@
                                 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 @@
                         }
                         else
                         {
-                            root = root->GetSyntheticArrayMemberFromPointer(index, true);
+                            root = root->GetSyntheticArrayMember(index, true);
                             if (!root.get())
                             {
                                 *first_unparsed = expression_cstr;
Index: source/DataFormatters/NSIndexPath.cpp
===================================================================
--- source/DataFormatters/NSIndexPath.cpp
+++ source/DataFormatters/NSIndexPath.cpp
@@ -278,7 +278,7 @@
 	    {
 	        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: source/Target/StackFrame.cpp
===================================================================
--- source/Target/StackFrame.cpp
+++ source/Target/StackFrame.cpp
@@ -920,7 +920,7 @@
                                     }
                                     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);
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to