Author: enrico
Date: Thu Sep 11 19:55:37 2014
New Revision: 217651

URL: http://llvm.org/viewvc/llvm-project?rev=217651&view=rev
Log:
Recent builds of libcxx actually wrap an std::map's children values in a union 
containing either a member named __cc, or either of __cc and __nc (const vs. 
non-const). This level of wrapping is quite useless for LLDB to show to people, 
so try to detect it, and filter it out

Modified:
    lldb/trunk/source/DataFormatters/LibCxxMap.cpp

Modified: lldb/trunk/source/DataFormatters/LibCxxMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxxMap.cpp?rev=217651&r1=217650&r2=217651&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxMap.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxxMap.cpp Thu Sep 11 19:55:37 2014
@@ -302,6 +302,10 @@ lldb_private::formatters::LibcxxStdMapSy
 lldb::ValueObjectSP
 lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex 
(size_t idx)
 {
+    static ConstString g___cc("__cc");
+    static ConstString g___nc("__nc");
+
+    
     if (idx >= CalculateNumChildren())
         return lldb::ValueObjectSP();
     if (m_tree == NULL || m_root_node == NULL)
@@ -375,7 +379,31 @@ lldb_private::formatters::LibcxxStdMapSy
     }
     StreamString name;
     name.Printf("[%" PRIu64 "]", (uint64_t)idx);
-    return (m_children[idx] = 
ValueObject::CreateValueObjectFromData(name.GetData(), data, 
m_backend.GetExecutionContextRef(), m_element_type));
+    auto potential_child_sp = 
ValueObject::CreateValueObjectFromData(name.GetData(), data, 
m_backend.GetExecutionContextRef(), m_element_type);
+    if (potential_child_sp)
+    {
+        switch (potential_child_sp->GetNumChildren())
+        {
+            case 1:
+            {
+                auto child0_sp = potential_child_sp->GetChildAtIndex(0, true);
+                if (child0_sp && child0_sp->GetName() == g___cc)
+                    potential_child_sp = child0_sp;
+                break;
+            }
+            case 2:
+            {
+                auto child0_sp = potential_child_sp->GetChildAtIndex(0, true);
+                auto child1_sp = potential_child_sp->GetChildAtIndex(1, true);
+                if (child0_sp && child0_sp->GetName() == g___cc &&
+                    child1_sp && child1_sp->GetName() == g___nc)
+                    potential_child_sp = child0_sp;
+                break;
+            }
+        }
+        potential_child_sp->SetName(ConstString(name.GetData()));
+    }
+    return (m_children[idx] = potential_child_sp);
 }
 
 bool


_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to