1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

[DWARF][NFC] Refactor a function to return Optional<> instead of bool

Minor refactor of DWARFUnit::getStringOffsetSectionItem().

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

llvm-svn: 345776
This commit is contained in:
Wolfgang Pieb 2018-10-31 21:05:51 +00:00
parent 7fc20ab496
commit e5c94ce536
3 changed files with 10 additions and 10 deletions

View File

@ -304,7 +304,7 @@ public:
}
Optional<SectionedAddress> getAddrOffsetSectionItem(uint32_t Index) const;
bool getStringOffsetSectionItem(uint32_t Index, uint64_t &Result) const;
Optional<uint64_t> getStringOffsetSectionItem(uint32_t Index) const;
DWARFDataExtractor getDebugInfoExtractor() const;

View File

@ -542,10 +542,12 @@ Optional<const char *> DWARFFormValue::getAsCString() const {
if (Form == DW_FORM_GNU_str_index || Form == DW_FORM_strx ||
Form == DW_FORM_strx1 || Form == DW_FORM_strx2 || Form == DW_FORM_strx3 ||
Form == DW_FORM_strx4) {
uint64_t StrOffset;
if (!U || !U->getStringOffsetSectionItem(Offset, StrOffset))
if (!U)
return None;
Offset = StrOffset;
Optional<uint64_t> StrOffset = U->getStringOffsetSectionItem(Offset);
if (!StrOffset)
return None;
Offset = *StrOffset;
}
// Prefer the Unit's string extractor, because for .dwo it will point to
// .debug_str.dwo, while the Context's extractor always uses .debug_str.

View File

@ -217,18 +217,16 @@ DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const {
return {{Address, Section}};
}
bool DWARFUnit::getStringOffsetSectionItem(uint32_t Index,
uint64_t &Result) const {
Optional<uint64_t> DWARFUnit::getStringOffsetSectionItem(uint32_t Index) const {
if (!StringOffsetsTableContribution)
return false;
return None;
unsigned ItemSize = getDwarfStringOffsetsByteSize();
uint32_t Offset = getStringOffsetsBase() + Index * ItemSize;
if (StringOffsetSection.Data.size() < Offset + ItemSize)
return false;
return None;
DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection,
isLittleEndian, 0);
Result = DA.getRelocatedValue(ItemSize, &Offset);
return true;
return DA.getRelocatedValue(ItemSize, &Offset);
}
bool DWARFUnitHeader::extract(DWARFContext &Context,