This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB355974: Remove DWARFDIECollection. (authored by zturner, 
committed by ).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D59165?vs=189961&id=190325#toc

Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59165/new/

https://reviews.llvm.org/D59165

Files:
  source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
  source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDIE.h
  source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -54,8 +54,7 @@
   ScopedExtractDIEs ExtractDIEsScoped();
 
   DWARFDIE LookupAddress(const dw_addr_t address);
-  size_t AppendDIEsWithTag(const dw_tag_t tag,
-                           DWARFDIECollection &matching_dies,
+  size_t AppendDIEsWithTag(const dw_tag_t tag, std::vector<DWARFDIE> &dies,
                            uint32_t depth = UINT32_MAX) const;
   bool Verify(lldb_private::Stream *s) const;
   virtual void Dump(lldb_private::Stream *s) const = 0;
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -18,7 +18,6 @@
 #include "lldb/Utility/Stream.h"
 
 #include "DWARFUnit.h"
-#include "DWARFDIECollection.h"
 #include "DWARFDebugAbbrev.h"
 #include "DWARFDebugAranges.h"
 #include "DWARFDebugInfo.h"
@@ -1381,11 +1380,11 @@
   }
 }
 
-void DWARFDebugInfoEntry::GetDeclContextDIEs(
-    DWARFUnit *cu, DWARFDIECollection &decl_context_dies) const {
+std::vector<DWARFDIE>
+DWARFDebugInfoEntry::GetDeclContextDIEs(DWARFUnit *cu) const {
 
   DWARFDIE die(cu, const_cast<DWARFDebugInfoEntry *>(this));
-  die.GetDeclContextDIEs(decl_context_dies);
+  return die.GetDeclContextDIEs();
 }
 
 void DWARFDebugInfoEntry::GetDWARFDeclContext(
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===================================================================
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -49,7 +49,6 @@
 class DWARFDebugLine;
 class DWARFDebugRangesBase;
 class DWARFDeclContext;
-class DWARFDIECollection;
 class DWARFFormValue;
 class SymbolFileDWARFDebugMap;
 class SymbolFileDWARFDwo;
Index: source/Plugins/SymbolFile/DWARF/CMakeLists.txt
===================================================================
--- source/Plugins/SymbolFile/DWARF/CMakeLists.txt
+++ source/Plugins/SymbolFile/DWARF/CMakeLists.txt
@@ -21,7 +21,6 @@
   DWARFDeclContext.cpp
   DWARFDefines.cpp
   DWARFDIE.cpp
-  DWARFDIECollection.cpp
   DWARFFormValue.cpp
   DWARFIndex.cpp
   DWARFUnit.cpp
Index: source/Plugins/SymbolFile/DWARF/DWARFDIE.h
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -81,7 +81,7 @@
   //----------------------------------------------------------------------
   // DeclContext related functions
   //----------------------------------------------------------------------
-  void GetDeclContextDIEs(DWARFDIECollection &decl_context_dies) const;
+  std::vector<DWARFDIE> GetDeclContextDIEs() const;
 
   void GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const;
 
Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -230,8 +230,7 @@
     return HasChildren() ? this + 1 : NULL;
   }
 
-  void GetDeclContextDIEs(DWARFUnit *cu,
-                          DWARFDIECollection &decl_context_dies) const;
+  std::vector<DWARFDIE> GetDeclContextDIEs(DWARFUnit *cu) const;
 
   void GetDWARFDeclContext(SymbolFileDWARF *dwarf2Data, DWARFUnit *cu,
                            DWARFDeclContext &dwarf_decl_ctx) const;
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -17,7 +17,6 @@
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Timer.h"
 
-#include "DWARFDIECollection.h"
 #include "DWARFDebugAranges.h"
 #include "DWARFDebugInfo.h"
 #include "LogChannelDWARF.h"
@@ -400,24 +399,23 @@
 }
 
 size_t DWARFUnit::AppendDIEsWithTag(const dw_tag_t tag,
-				    DWARFDIECollection &dies,
-				    uint32_t depth) const {
-  size_t old_size = dies.Size();
+                                    std::vector<DWARFDIE> &dies,
+                                    uint32_t depth) const {
+  size_t old_size = dies.size();
   {
     llvm::sys::ScopedReader lock(m_die_array_mutex);
     DWARFDebugInfoEntry::const_iterator pos;
     DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
     for (pos = m_die_array.begin(); pos != end; ++pos) {
       if (pos->Tag() == tag)
-        dies.Append(DWARFDIE(this, &(*pos)));
+        dies.emplace_back(this, &(*pos));
     }
   }
 
   // Return the number of DIEs added to the collection
-  return dies.Size() - old_size;
+  return dies.size() - old_size;
 }
 
-
 lldb::user_id_t DWARFUnit::GetID() const {
   dw_offset_t local_id =
       m_base_obj_offset != DW_INVALID_OFFSET ? m_base_obj_offset : m_offset;
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -54,7 +54,6 @@
 #include "AppleDWARFIndex.h"
 #include "DWARFASTParser.h"
 #include "DWARFASTParserClang.h"
-#include "DWARFDIECollection.h"
 #include "DWARFDebugAbbrev.h"
 #include "DWARFDebugAranges.h"
 #include "DWARFDebugInfo.h"
@@ -861,22 +860,20 @@
 
 size_t SymbolFileDWARF::ParseFunctions(CompileUnit &comp_unit) {
   ASSERT_MODULE_LOCK(this);
-  size_t functions_added = 0;
   DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
-  if (dwarf_cu) {
-    DWARFDIECollection function_dies;
-    const size_t num_functions =
-        dwarf_cu->AppendDIEsWithTag(DW_TAG_subprogram, function_dies);
-    size_t func_idx;
-    for (func_idx = 0; func_idx < num_functions; ++func_idx) {
-      DWARFDIE die = function_dies.GetDIEAtIndex(func_idx);
-      if (comp_unit.FindFunctionByUID(die.GetID()).get() == NULL) {
-        if (ParseFunction(comp_unit, die))
-          ++functions_added;
-      }
-    }
-    // FixupTypes();
+  if (!dwarf_cu)
+    return 0;
+
+  size_t functions_added = 0;
+  std::vector<DWARFDIE> function_dies;
+  dwarf_cu->AppendDIEsWithTag(DW_TAG_subprogram, function_dies);
+  for (const DWARFDIE &die : function_dies) {
+    if (comp_unit.FindFunctionByUID(die.GetID()))
+      continue;
+    if (ParseFunction(comp_unit, die))
+      ++functions_added;
   }
+  // FixupTypes();
   return functions_added;
 }
 
@@ -2807,8 +2804,8 @@
   if (die1 == die2)
     return true;
 
-  DWARFDIECollection decl_ctx_1;
-  DWARFDIECollection decl_ctx_2;
+  std::vector<DWARFDIE> decl_ctx_1;
+  std::vector<DWARFDIE> decl_ctx_2;
   // The declaration DIE stack is a stack of the declaration context DIEs all
   // the way back to the compile unit. If a type "T" is declared inside a class
   // "B", and class "B" is declared inside a class "A" and class "A" is in a
@@ -2824,11 +2821,11 @@
   // back to the compiler unit.
 
   // First lets grab the decl contexts for both DIEs
-  die1.GetDeclContextDIEs(decl_ctx_1);
-  die2.GetDeclContextDIEs(decl_ctx_2);
+  decl_ctx_1 = die1.GetDeclContextDIEs();
+  decl_ctx_2 = die2.GetDeclContextDIEs();
   // Make sure the context arrays have the same size, otherwise we are done
-  const size_t count1 = decl_ctx_1.Size();
-  const size_t count2 = decl_ctx_2.Size();
+  const size_t count1 = decl_ctx_1.size();
+  const size_t count2 = decl_ctx_2.size();
   if (count1 != count2)
     return false;
 
@@ -2838,8 +2835,8 @@
   DWARFDIE decl_ctx_die2;
   size_t i;
   for (i = 0; i < count1; i++) {
-    decl_ctx_die1 = decl_ctx_1.GetDIEAtIndex(i);
-    decl_ctx_die2 = decl_ctx_2.GetDIEAtIndex(i);
+    decl_ctx_die1 = decl_ctx_1[i];
+    decl_ctx_die2 = decl_ctx_2[i];
     if (decl_ctx_die1.Tag() != decl_ctx_die2.Tag())
       return false;
   }
@@ -2849,7 +2846,7 @@
   // DW_TAG_compile_unit or DW_TAG_partial_unit. If it isn't then
   // something went wrong in the DWARFDIE::GetDeclContextDIEs()
   // function.
-  dw_tag_t cu_tag = decl_ctx_1.GetDIEAtIndex(count1 - 1).Tag();
+  dw_tag_t cu_tag = decl_ctx_1[count1 - 1].Tag();
   UNUSED_IF_ASSERT_DISABLED(cu_tag);
   assert(cu_tag == DW_TAG_compile_unit || cu_tag == DW_TAG_partial_unit);
 
@@ -2857,8 +2854,8 @@
   // Always skip the compile unit when comparing by only iterating up to "count
   // - 1". Here we compare the names as we go.
   for (i = 0; i < count1 - 1; i++) {
-    decl_ctx_die1 = decl_ctx_1.GetDIEAtIndex(i);
-    decl_ctx_die2 = decl_ctx_2.GetDIEAtIndex(i);
+    decl_ctx_die1 = decl_ctx_1[i];
+    decl_ctx_die2 = decl_ctx_2[i];
     const char *name1 = decl_ctx_die1.GetName();
     const char *name2 = decl_ctx_die2.GetName();
     // If the string was from a DW_FORM_strp, then the pointer will often be
Index: source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -9,7 +9,6 @@
 #include "DWARFDIE.h"
 
 #include "DWARFASTParser.h"
-#include "DWARFDIECollection.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDebugInfoEntry.h"
 #include "DWARFDeclContext.h"
@@ -200,15 +199,18 @@
     return nullptr;
 }
 
-void DWARFDIE::GetDeclContextDIEs(DWARFDIECollection &decl_context_dies) const {
-  if (IsValid()) {
-    DWARFDIE parent_decl_ctx_die =
-        m_die->GetParentDeclContextDIE(GetDWARF(), GetCU());
-    if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != GetDIE()) {
-      decl_context_dies.Append(parent_decl_ctx_die);
-      parent_decl_ctx_die.GetDeclContextDIEs(decl_context_dies);
-    }
+std::vector<DWARFDIE> DWARFDIE::GetDeclContextDIEs() const {
+  if (!IsValid())
+    return {};
+
+  std::vector<DWARFDIE> result;
+  DWARFDIE parent = GetParentDeclContextDIE();
+  while (parent.IsValid() && parent.GetDIE() != GetDIE()) {
+    result.push_back(std::move(parent));
+    parent = parent.GetParentDeclContextDIE();
   }
+
+  return result;
 }
 
 void DWARFDIE::GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const {
Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -21,11 +21,12 @@
 #include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangASTImporter.h"
 
+#include <vector>
+
 namespace lldb_private {
 class CompileUnit;
 }
 class DWARFDebugInfoEntry;
-class DWARFDIECollection;
 class SymbolFileDWARF;
 
 class DWARFASTParserClang : public DWARFASTParser {
@@ -85,7 +86,7 @@
       const lldb::LanguageType class_language,
       std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
       std::vector<int> &member_accessibilities,
-      DWARFDIECollection &member_function_dies,
+      std::vector<DWARFDIE> &member_function_dies,
       DelayedPropertyList &delayed_properties,
       lldb::AccessType &default_accessibility, bool &is_a_class,
       lldb_private::ClangASTImporter::LayoutInfo &layout_info);
@@ -117,7 +118,7 @@
   bool CopyUniqueClassMethodTypes(const DWARFDIE &src_class_die,
                                   const DWARFDIE &dst_class_die,
                                   lldb_private::Type *class_type,
-                                  DWARFDIECollection &failures);
+                                  std::vector<DWARFDIE> &failures);
 
   clang::DeclContext *GetCachedClangDeclContextForDIE(const DWARFDIE &die);
 
Index: source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
+++ source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
@@ -18,7 +18,6 @@
 class DWARFUnit;
 class DWARFDebugInfoEntry;
 class DWARFDeclContext;
-class DWARFDIECollection;
 class SymbolFileDWARF;
 
 class DWARFBaseDIE {
Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -10,7 +10,6 @@
 
 #include "DWARFASTParserClang.h"
 #include "DWARFDIE.h"
-#include "DWARFDIECollection.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDeclContext.h"
 #include "DWARFDefines.h"
@@ -1393,7 +1392,7 @@
                         DIERef(class_type->GetID(), dwarf));
                   }
                   if (class_type_die) {
-                    DWARFDIECollection failures;
+                    std::vector<DWARFDIE> failures;
 
                     CopyUniqueClassMethodTypes(decl_ctx_die, class_type_die,
                                                class_type, failures);
@@ -2194,7 +2193,7 @@
         std::vector<int> member_accessibilities;
         bool is_a_class = false;
         // Parse members and base classes first
-        DWARFDIECollection member_function_dies;
+        std::vector<DWARFDIE> member_function_dies;
 
         DelayedPropertyList delayed_properties;
         ParseChildMembers(sc, die, clang_type, class_language, bases,
@@ -2203,12 +2202,8 @@
                           layout_info);
 
         // Now parse any methods if there were any...
-        size_t num_functions = member_function_dies.Size();
-        if (num_functions > 0) {
-          for (size_t i = 0; i < num_functions; ++i) {
-            dwarf->ResolveType(member_function_dies.GetDIEAtIndex(i));
-          }
-        }
+        for (const DWARFDIE &die : member_function_dies)
+          dwarf->ResolveType(die);
 
         if (class_language == eLanguageTypeObjC) {
           ConstString class_name(clang_type.GetTypeName());
@@ -2677,7 +2672,7 @@
     CompilerType &class_clang_type, const LanguageType class_language,
     std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
     std::vector<int> &member_accessibilities,
-    DWARFDIECollection &member_function_dies,
+    std::vector<DWARFDIE> &member_function_dies,
     DelayedPropertyList &delayed_properties, AccessType &default_accessibility,
     bool &is_a_class, ClangASTImporter::LayoutInfo &layout_info) {
   if (!parent_die)
@@ -3176,7 +3171,7 @@
 
     case DW_TAG_subprogram:
       // Let the type parsing code handle this one for us.
-      member_function_dies.Append(die);
+      member_function_dies.push_back(die);
       break;
 
     case DW_TAG_inheritance: {
@@ -3872,7 +3867,7 @@
 
 bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
     const DWARFDIE &src_class_die, const DWARFDIE &dst_class_die,
-    lldb_private::Type *class_type, DWARFDIECollection &failures) {
+    lldb_private::Type *class_type, std::vector<DWARFDIE> &failures) {
   if (!class_type || !src_class_die || !dst_class_die)
     return false;
   if (src_class_die.Tag() != dst_class_die.Tag())
@@ -4077,7 +4072,7 @@
             log->Printf("warning: couldn't find a match for 0x%8.8x",
                         dst_die.GetOffset());
 
-          failures.Append(dst_die);
+          failures.push_back(dst_die);
         }
       }
     }
@@ -4142,9 +4137,9 @@
                     "method '%s'",
                     dst_die.GetOffset(), dst_name_artificial.GetCString());
 
-      failures.Append(dst_die);
+      failures.push_back(dst_die);
     }
   }
 
-  return (failures.Size() != 0);
+  return !failures.empty();
 }
Index: source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h
+++ source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h
@@ -1,37 +0,0 @@
-//===-- DWARFDIECollection.h ------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef SymbolFileDWARF_DWARFDIECollection_h_
-#define SymbolFileDWARF_DWARFDIECollection_h_
-
-#include "DWARFDIE.h"
-#include <vector>
-
-class DWARFDIECollection {
-public:
-  DWARFDIECollection() : m_dies() {}
-  ~DWARFDIECollection() {}
-
-  void Append(const DWARFDIE &die);
-
-  void Dump(lldb_private::Stream *s, const char *title) const;
-
-  DWARFDIE
-  GetDIEAtIndex(uint32_t idx) const;
-
-  size_t Size() const;
-
-protected:
-  typedef std::vector<DWARFDIE> collection;
-  typedef collection::iterator iterator;
-  typedef collection::const_iterator const_iterator;
-
-  collection m_dies; // Ordered list of die offsets
-};
-
-#endif // SymbolFileDWARF_DWARFDIECollection_h_
Index: source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
@@ -1,34 +0,0 @@
-//===-- DWARFDIECollection.cpp ----------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "DWARFDIECollection.h"
-
-#include <algorithm>
-
-#include "lldb/Utility/Stream.h"
-
-using namespace lldb_private;
-using namespace std;
-
-void DWARFDIECollection::Append(const DWARFDIE &die) { m_dies.push_back(die); }
-
-DWARFDIE
-DWARFDIECollection::GetDIEAtIndex(uint32_t idx) const {
-  if (idx < m_dies.size())
-    return m_dies[idx];
-  return DWARFDIE();
-}
-
-size_t DWARFDIECollection::Size() const { return m_dies.size(); }
-
-void DWARFDIECollection::Dump(Stream *s, const char *title) const {
-  if (title && title[0] != '\0')
-    s->Printf("%s\n", title);
-  for (const auto &die : m_dies)
-    s->Printf("0x%8.8x\n", die.GetOffset());
-}
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to