[Lldb-commits] [lldb] r283167 - Fix the data formatter for std::multiset in libc++ - this is a trivial amount of extra change on top of multimap

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 3 17:07:42 PDT 2016


Author: enrico
Date: Mon Oct  3 19:07:42 2016
New Revision: 283167

URL: http://llvm.org/viewvc/llvm-project?rev=283167&view=rev
Log:
Fix the data formatter for std::multiset in libc++ - this is a trivial amount of extra change on top of multimap

Also, proper formatting..


Modified:
    lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp?rev=283167&r1=283166&r2=283167&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp Mon Oct  3 19:07:42 2016
@@ -39,21 +39,26 @@ public:
     static ConstString g_left("__left_");
     if (!m_entry_sp)
       return m_entry_sp;
-    return m_entry_sp->GetSyntheticChildAtOffset(0, m_entry_sp->GetCompilerType(), true);
+    return m_entry_sp->GetSyntheticChildAtOffset(
+        0, m_entry_sp->GetCompilerType(), true);
   }
 
   ValueObjectSP right() const {
     static ConstString g_right("__right_");
     if (!m_entry_sp)
       return m_entry_sp;
-    return m_entry_sp->GetSyntheticChildAtOffset(m_entry_sp->GetProcessSP()->GetAddressByteSize(), m_entry_sp->GetCompilerType(), true);
+    return m_entry_sp->GetSyntheticChildAtOffset(
+        m_entry_sp->GetProcessSP()->GetAddressByteSize(),
+        m_entry_sp->GetCompilerType(), true);
   }
 
   ValueObjectSP parent() const {
     static ConstString g_parent("__parent_");
     if (!m_entry_sp)
       return m_entry_sp;
-    return m_entry_sp->GetSyntheticChildAtOffset(2*m_entry_sp->GetProcessSP()->GetAddressByteSize(), m_entry_sp->GetCompilerType(), true);
+    return m_entry_sp->GetSyntheticChildAtOffset(
+        2 * m_entry_sp->GetProcessSP()->GetAddressByteSize(),
+        m_entry_sp->GetCompilerType(), true);
   }
 
   uint64_t value() const {
@@ -244,20 +249,29 @@ bool lldb_private::formatters::LibcxxStd
     return false;
   deref = deref->GetChildMemberWithName(g___value_, true);
   if (deref) {
-      m_element_type = deref->GetCompilerType();
-      return true;
+    m_element_type = deref->GetCompilerType();
+    return true;
   }
   lldb::TemplateArgumentKind kind;
-  deref = m_backend.GetChildAtNamePath( {g_tree_, g_pair3} );
+  deref = m_backend.GetChildAtNamePath({g_tree_, g_pair3});
   if (!deref)
     return false;
-  m_element_type = deref->GetCompilerType().GetTemplateArgument(1, kind).GetTemplateArgument(1, kind);
-  if (!m_element_type)
-    return false;
-  std::string name; uint64_t bit_offset_ptr; uint32_t bitfield_bit_size_ptr; bool is_bitfield_ptr;
-  m_element_type = m_element_type.GetFieldAtIndex(0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
-  m_element_type = m_element_type.GetTypedefedType();
-  return m_element_type.IsValid();
+  m_element_type =
+      deref->GetCompilerType().GetTemplateArgument(1, kind).GetTemplateArgument(
+          1, kind);
+  if (m_element_type) {
+    std::string name;
+    uint64_t bit_offset_ptr;
+    uint32_t bitfield_bit_size_ptr;
+    bool is_bitfield_ptr;
+    m_element_type = m_element_type.GetFieldAtIndex(
+        0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
+    m_element_type = m_element_type.GetTypedefedType();
+    return m_element_type.IsValid();
+  } else {
+    m_element_type = m_backend.GetCompilerType().GetTemplateArgument(0, kind);
+    return m_element_type.IsValid();
+  }
 }
 
 void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset(
@@ -271,18 +285,18 @@ void lldb_private::formatters::LibcxxStd
   if (node_type.GetIndexOfFieldWithName("__value_", nullptr, &bit_offset) !=
       UINT32_MAX) {
     m_skip_size = bit_offset / 8u;
-  }
-  else {
-    ClangASTContext *ast_ctx = llvm::dyn_cast_or_null<ClangASTContext>(node_type.GetTypeSystem());
+  } else {
+    ClangASTContext *ast_ctx =
+        llvm::dyn_cast_or_null<ClangASTContext>(node_type.GetTypeSystem());
     if (!ast_ctx)
       return;
-    CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(ConstString(), {
-      {"ptr0",ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
-      {"ptr1",ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
-      {"ptr2",ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
-      {"cw",ast_ctx->GetBasicType(lldb::eBasicTypeBool)},
-      {"payload",m_element_type}
-    });
+    CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
+        ConstString(),
+        {{"ptr0", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
+         {"ptr1", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
+         {"ptr2", ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
+         {"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)},
+         {"payload", (m_element_type.GetCompleteType(), m_element_type)}});
     std::string child_name;
     uint32_t child_byte_size;
     int32_t child_byte_offset = 0;
@@ -291,7 +305,13 @@ void lldb_private::formatters::LibcxxStd
     bool child_is_base_class;
     bool child_is_deref_of_parent;
     uint64_t language_flags;
-    if (tree_node_type.GetChildCompilerTypeAtIndex(nullptr, 4, true, true, true, child_name, child_byte_size, child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, child_is_deref_of_parent, nullptr, language_flags).IsValid())
+    if (tree_node_type
+            .GetChildCompilerTypeAtIndex(
+                nullptr, 4, true, true, true, child_name, child_byte_size,
+                child_byte_offset, child_bitfield_bit_size,
+                child_bitfield_bit_offset, child_is_base_class,
+                child_is_deref_of_parent, nullptr, language_flags)
+            .IsValid())
       m_skip_size = (uint32_t)child_byte_offset;
   }
 }
@@ -341,7 +361,7 @@ lldb_private::formatters::LibcxxStdMapSy
         iterated_sp = child_sp;
       else
         iterated_sp = iterated_sp->GetSyntheticChildAtOffset(
-                                                             m_skip_size, m_element_type, true);
+            m_skip_size, m_element_type, true);
       if (!iterated_sp) {
         m_tree = nullptr;
         return lldb::ValueObjectSP();




More information about the lldb-commits mailing list