[DebugInfo] Rename getOffset() to getContribution(). NFC.

The old name was a bit misleading because the functions actually return
contributions to the corresponding sections.

Differential revision: https://reviews.llvm.org/D77302
This commit is contained in:
Igor Kudrin 2020-04-02 19:39:56 +07:00
parent 69c8fb1c65
commit f13ce15d44
7 changed files with 21 additions and 19 deletions

View File

@ -263,7 +263,8 @@ void DWARFUnit::SetDwoStrOffsetsBase() {
lldb::offset_t baseOffset = 0;
if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
if (const auto *contribution = entry->getOffset(llvm::DW_SECT_STR_OFFSETS))
if (const auto *contribution =
entry->getContribution(llvm::DW_SECT_STR_OFFSETS))
baseOffset = contribution->Offset;
else
return;
@ -479,7 +480,7 @@ DWARFDataExtractor DWARFUnit::GetLocationData() const {
const DWARFDataExtractor &data =
GetVersion() >= 5 ? Ctx.getOrLoadLocListsData() : Ctx.getOrLoadLocData();
if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
if (const auto *contribution = entry->getOffset(llvm::DW_SECT_LOC))
if (const auto *contribution = entry->getContribution(llvm::DW_SECT_LOC))
return DWARFDataExtractor(data, contribution->Offset,
contribution->Length);
return DWARFDataExtractor();
@ -815,12 +816,13 @@ DWARFUnitHeader::extract(const DWARFDataExtractor &data,
llvm::inconvertibleErrorCode(),
"Package unit with a non-zero abbreviation offset");
}
auto *unit_contrib = header.m_index_entry->getOffset();
auto *unit_contrib = header.m_index_entry->getContribution();
if (!unit_contrib || unit_contrib->Length != header.m_length + 4) {
return llvm::createStringError(llvm::inconvertibleErrorCode(),
"Inconsistent DWARF package unit index");
}
auto *abbr_entry = header.m_index_entry->getOffset(llvm::DW_SECT_ABBREV);
auto *abbr_entry =
header.m_index_entry->getContribution(llvm::DW_SECT_ABBREV);
if (!abbr_entry) {
return llvm::createStringError(
llvm::inconvertibleErrorCode(),

View File

@ -38,7 +38,7 @@ SymbolFileDWARFDwo::SymbolFileDWARFDwo(SymbolFileDWARF &base_symbol_file,
DWARFCompileUnit *SymbolFileDWARFDwo::GetDWOCompileUnitForHash(uint64_t hash) {
if (const llvm::DWARFUnitIndex &index = m_context.GetAsLLVM().getCUIndex()) {
if (const llvm::DWARFUnitIndex::Entry *entry = index.getFromHash(hash)) {
if (auto *unit_contrib = entry->getOffset())
if (auto *unit_contrib = entry->getContribution())
return llvm::dyn_cast_or_null<DWARFCompileUnit>(
DebugInfo().GetUnitAtOffset(DIERef::Section::DebugInfo,
unit_contrib->Offset));

View File

@ -487,7 +487,7 @@ public:
uint32_t getLineTableOffset() const {
if (auto IndexEntry = Header.getIndexEntry())
if (const auto *Contrib = IndexEntry->getOffset(DW_SECT_LINE))
if (const auto *Contrib = IndexEntry->getContribution(DW_SECT_LINE))
return Contrib->Offset;
return 0;
}

View File

@ -56,10 +56,10 @@ public:
friend class DWARFUnitIndex;
public:
const SectionContribution *getOffset(DWARFSectionKind Sec) const;
const SectionContribution *getOffset() const;
const SectionContribution *getContribution(DWARFSectionKind Sec) const;
const SectionContribution *getContribution() const;
const SectionContribution *getOffsets() const {
const SectionContribution *getContributions() const {
return Contributions.get();
}

View File

@ -139,7 +139,7 @@ DWARFUnit *DWARFUnitVector::getUnitForOffset(uint64_t Offset) const {
DWARFUnit *
DWARFUnitVector::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) {
const auto *CUOff = E.getOffset(DW_SECT_INFO);
const auto *CUOff = E.getContribution(DW_SECT_INFO);
if (!CUOff)
return nullptr;
@ -183,7 +183,7 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
// data based on the index entries.
StringRef Data = LocSection->Data;
if (auto *IndexEntry = Header.getIndexEntry())
if (const auto *C = IndexEntry->getOffset(DW_SECT_LOC))
if (const auto *C = IndexEntry->getContribution(DW_SECT_LOC))
Data = Data.substr(C->Offset, C->Length);
DWARFDataExtractor DWARFData =
@ -294,11 +294,11 @@ bool DWARFUnitHeader::extract(DWARFContext &Context,
if (IndexEntry) {
if (AbbrOffset)
return false;
auto *UnitContrib = IndexEntry->getOffset();
auto *UnitContrib = IndexEntry->getContribution();
if (!UnitContrib ||
UnitContrib->Length != (Length + getUnitLengthFieldByteSize()))
return false;
auto *AbbrEntry = IndexEntry->getOffset(DW_SECT_ABBREV);
auto *AbbrEntry = IndexEntry->getContribution(DW_SECT_ABBREV);
if (!AbbrEntry)
return false;
AbbrOffset = AbbrEntry->Offset;
@ -966,7 +966,7 @@ DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor & DA) {
uint64_t Offset = 0;
auto IndexEntry = Header.getIndexEntry();
const auto *C =
IndexEntry ? IndexEntry->getOffset(DW_SECT_STR_OFFSETS) : nullptr;
IndexEntry ? IndexEntry->getContribution(DW_SECT_STR_OFFSETS) : nullptr;
if (C)
Offset = C->Offset;
if (getVersion() >= 5) {

View File

@ -154,7 +154,7 @@ void DWARFUnitIndex::dump(raw_ostream &OS) const {
}
const DWARFUnitIndex::Entry::SectionContribution *
DWARFUnitIndex::Entry::getOffset(DWARFSectionKind Sec) const {
DWARFUnitIndex::Entry::getContribution(DWARFSectionKind Sec) const {
uint32_t i = 0;
for (; i != Index->Header.NumColumns; ++i)
if (Index->ColumnKinds[i] == Sec)
@ -163,7 +163,7 @@ DWARFUnitIndex::Entry::getOffset(DWARFSectionKind Sec) const {
}
const DWARFUnitIndex::Entry::SectionContribution *
DWARFUnitIndex::Entry::getOffset() const {
DWARFUnitIndex::Entry::getContribution() const {
return &Contributions[Index->InfoColumn];
}

View File

@ -219,7 +219,7 @@ struct UnitIndexEntry {
static StringRef getSubsection(StringRef Section,
const DWARFUnitIndex::Entry &Entry,
DWARFSectionKind Kind) {
const auto *Off = Entry.getOffset(Kind);
const auto *Off = Entry.getContribution(Kind);
if (!Off)
return StringRef();
return Section.substr(Off->Offset, Off->Length);
@ -231,7 +231,7 @@ static void addAllTypesFromDWP(
const UnitIndexEntry &TUEntry, uint32_t &TypesOffset) {
Out.SwitchSection(OutputTypes);
for (const DWARFUnitIndex::Entry &E : TUIndex.getRows()) {
auto *I = E.getOffsets();
auto *I = E.getContributions();
if (!I)
continue;
auto P = TypeIndexEntries.insert(std::make_pair(E.getSignature(), TUEntry));
@ -599,7 +599,7 @@ static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
return make_error<DWPError>("failed to parse cu_index");
for (const DWARFUnitIndex::Entry &E : CUIndex.getRows()) {
auto *I = E.getOffsets();
auto *I = E.getContributions();
if (!I)
continue;
auto P = IndexEntries.insert(std::make_pair(E.getSignature(), CurEntry));