forked from OSchip/llvm-project
[nfc] [lldb] Refactor DWARFUnit::GetDIE
Reduce indentation of the code by early returns for failed code paths.
This commit is contained in:
parent
4f98eaf655
commit
7611c5bb42
|
@ -525,21 +525,23 @@ static bool CompareDIEOffset(const DWARFDebugInfoEntry &die,
|
|||
// DIE from this compile unit. Otherwise we grab the DIE from the DWARF file.
|
||||
DWARFDIE
|
||||
DWARFUnit::GetDIE(dw_offset_t die_offset) {
|
||||
if (die_offset != DW_INVALID_OFFSET) {
|
||||
if (ContainsDIEOffset(die_offset)) {
|
||||
ExtractDIEsIfNeeded();
|
||||
DWARFDebugInfoEntry::const_iterator end = m_die_array.cend();
|
||||
DWARFDebugInfoEntry::const_iterator pos =
|
||||
lower_bound(m_die_array.cbegin(), end, die_offset, CompareDIEOffset);
|
||||
if (pos != end) {
|
||||
if (die_offset == (*pos).GetOffset())
|
||||
return DWARFDIE(this, &(*pos));
|
||||
}
|
||||
} else
|
||||
GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
|
||||
"GetDIE for DIE 0x%" PRIx32 " is outside of its CU 0x%" PRIx32,
|
||||
die_offset, GetOffset());
|
||||
if (die_offset == DW_INVALID_OFFSET)
|
||||
return DWARFDIE(); // Not found
|
||||
|
||||
if (!ContainsDIEOffset(die_offset)) {
|
||||
GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
|
||||
"GetDIE for DIE 0x%" PRIx32 " is outside of its CU 0x%" PRIx32,
|
||||
die_offset, GetOffset());
|
||||
return DWARFDIE(); // Not found
|
||||
}
|
||||
|
||||
ExtractDIEsIfNeeded();
|
||||
DWARFDebugInfoEntry::const_iterator end = m_die_array.cend();
|
||||
DWARFDebugInfoEntry::const_iterator pos =
|
||||
lower_bound(m_die_array.cbegin(), end, die_offset, CompareDIEOffset);
|
||||
|
||||
if (pos != end && die_offset == (*pos).GetOffset())
|
||||
return DWARFDIE(this, &(*pos));
|
||||
return DWARFDIE(); // Not found
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue