[Lldb-commits] [PATCH] D62943: DWARF: Simplify SymbolFileDWARF::GetDWARFCompileUnit

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 6 01:40:01 PDT 2019


labath created this revision.
labath added reviewers: clayborg, JDevlieghere.
Herald added subscribers: jdoerfert, aprantl.

The DWARFCompileUnit is set as the "user data" of the lldb compile unit
directly in the constructor (see ParseCompileUnit).

This means that instead of going through unit indexes, we can just fetch
the DWARF unit directly from there.


https://reviews.llvm.org/D62943

Files:
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -608,15 +608,7 @@
   if (!comp_unit)
     return nullptr;
 
-  DWARFDebugInfo *info = DebugInfo();
-  if (info) {
-    // The compile unit ID is the index of the DWARF unit.
-    DWARFUnit *dwarf_cu = info->GetUnitAtIndex(comp_unit->GetID());
-    if (dwarf_cu && dwarf_cu->GetUserData() == nullptr)
-      dwarf_cu->SetUserData(comp_unit);
-    return dwarf_cu;
-  }
-  return nullptr;
+  return static_cast<DWARFUnit *>(comp_unit->GetUserData());
 }
 
 DWARFDebugRangesBase *SymbolFileDWARF::GetDebugRanges() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62943.203304.patch
Type: text/x-patch
Size: 755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190606/a580198a/attachment-0001.bin>


More information about the lldb-commits mailing list