~pali/llvm/lldb-trunk

« back to all changes in this revision

Viewing changes to source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp

  • Committer: labath
  • Date: 2019-06-20 08:24:46 UTC
  • Revision ID: svn-v4:91177308-0d34-0410-b5e6-96231b3b80d8:lldb/trunk:363910
DWARF: Provide accessors to DIERef fields

Summary:
Instead of accessing the fields directly, use accessor functions to
provide access to the DIERef components. This allows us to decouple the
external interface, from the internal representation. The external
interface can use llvm::Optional and similar goodies, while the data can
still be stored internally in a more compact representation.

I also document the purpose of the existing DIERef fields.

The main motivation for this change is a need to introduce an additional
field to the DIERef class, but I believe the change has its own merit.

Reviewers: JDevlieghere, aprantl, clayborg

Subscribers: arphaman, lldb-commits

Differential Revision: https://reviews.llvm.org/D63400

Show diffs side-by-side

added added

removed removed

Lines of Context:
149
149
}
150
150
 
151
151
DWARFUnit *DWARFDebugInfo::GetUnit(const DIERef &die_ref) {
152
 
  if (die_ref.cu_offset == DW_INVALID_OFFSET)
153
 
    return GetUnitContainingDIEOffset(die_ref.section, die_ref.die_offset);
154
 
  else
155
 
    return GetUnitAtOffset(die_ref.section, die_ref.cu_offset);
 
152
  if (die_ref.unit_offset())
 
153
    return GetUnitAtOffset(die_ref.section(), *die_ref.unit_offset());
 
154
  return GetUnitContainingDIEOffset(die_ref.section(), die_ref.die_offset());
156
155
}
157
156
 
158
157
DWARFUnit *
194
193
DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
195
194
  DWARFUnit *cu = GetUnit(die_ref);
196
195
  if (cu)
197
 
    return cu->GetDIE(die_ref.die_offset);
 
196
    return cu->GetDIE(die_ref.die_offset());
198
197
  return DWARFDIE(); // Not found
199
198
}
200
199