[llvm] 636de2b - Change isLittleEndian to follow llvm style and add an accessor
Shubham Sandeep Rastogi via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 20 17:04:14 PDT 2022
Author: Shubham Sandeep Rastogi
Date: 2022-09-20T17:00:47-07:00
New Revision: 636de2bf342ebae9a1d4ccb9c0029e72c7ce6e26
URL: https://github.com/llvm/llvm-project/commit/636de2bf342ebae9a1d4ccb9c0029e72c7ce6e26
DIFF: https://github.com/llvm/llvm-project/commit/636de2bf342ebae9a1d4ccb9c0029e72c7ce6e26.diff
LOG: Change isLittleEndian to follow llvm style and add an accessor
Differential Revision: https://reviews.llvm.org/D134290
Added:
Modified:
llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
index fd704b1136839..be95e706a5825 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -224,7 +224,7 @@ class DWARFUnit {
const DWARFSection *AddrOffsetSection;
DWARFUnit *SU;
Optional<uint64_t> AddrOffsetSectionBase;
- bool isLittleEndian;
+ bool IsLittleEndian;
bool IsDWO;
const DWARFUnitVector &UnitVector;
@@ -307,6 +307,7 @@ class DWARFUnit {
virtual ~DWARFUnit();
+ bool isLittleEndian() const { return IsLittleEndian; }
bool isDWOUnit() const { return IsDWO; }
DWARFContext& getContext() const { return Context; }
const DWARFSection &getInfoSection() const { return InfoSection; }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 7f7581a928a24..58b59df4cb414 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -192,7 +192,7 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
bool IsDWO, const DWARFUnitVector &UnitVector)
: Context(DC), InfoSection(Section), Header(Header), Abbrev(DA),
RangeSection(RS), LineSection(LS), StringSection(SS),
- StringOffsetSection(SOS), AddrOffsetSection(AOS), isLittleEndian(LE),
+ StringOffsetSection(SOS), AddrOffsetSection(AOS), IsLittleEndian(LE),
IsDWO(IsDWO), UnitVector(UnitVector) {
clear();
}
@@ -200,7 +200,7 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
DWARFUnit::~DWARFUnit() = default;
DWARFDataExtractor DWARFUnit::getDebugInfoExtractor() const {
- return DWARFDataExtractor(Context.getDWARFObj(), InfoSection, isLittleEndian,
+ return DWARFDataExtractor(Context.getDWARFObj(), InfoSection, IsLittleEndian,
getAddressByteSize());
}
@@ -222,7 +222,7 @@ DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const {
if (AddrOffsetSection->Data.size() < Offset + getAddressByteSize())
return None;
DWARFDataExtractor DA(Context.getDWARFObj(), *AddrOffsetSection,
- isLittleEndian, getAddressByteSize());
+ IsLittleEndian, getAddressByteSize());
uint64_t Section;
uint64_t Address = DA.getRelocatedAddress(&Offset, &Section);
return {{Address, Section}};
@@ -240,7 +240,7 @@ Expected<uint64_t> DWARFUnit::getStringOffsetSectionItem(uint32_t Index) const {
", which is too large",
inconvertibleErrorCode());
DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection,
- isLittleEndian, 0);
+ IsLittleEndian, 0);
return DA.getRelocatedValue(ItemSize, &Offset);
}
@@ -367,7 +367,7 @@ Error DWARFUnit::extractRangeList(uint64_t RangeListOffset,
// Require that compile unit is extracted.
assert(!DieArray.empty());
DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection,
- isLittleEndian, getAddressByteSize());
+ IsLittleEndian, getAddressByteSize());
uint64_t ActualRangeListOffset = RangeSectionBase + RangeListOffset;
return RangeList.extract(RangesData, &ActualRangeListOffset);
}
@@ -521,7 +521,7 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
// In both cases we need to determine the format of the contribution,
// which may
diff er from the unit's format.
DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection,
- isLittleEndian, 0);
+ IsLittleEndian, 0);
if (IsDWO || getVersion() >= 5) {
auto StringOffsetOrError =
IsDWO ? determineStringOffsetsTableContributionDWO(DA)
@@ -566,7 +566,7 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
Header.getVersion() >= 5 ? DW_SECT_LOCLISTS : DW_SECT_EXT_LOC))
Data = Data.substr(C->Offset, C->Length);
- DWARFDataExtractor DWARFData(Data, isLittleEndian, getAddressByteSize());
+ DWARFDataExtractor DWARFData(Data, IsLittleEndian, getAddressByteSize());
LocTable =
std::make_unique<DWARFDebugLoclists>(DWARFData, Header.getVersion());
LocSectionBase = DWARFListTableHeader::getHeaderSize(Header.getFormat());
@@ -574,12 +574,12 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
LocTable = std::make_unique<DWARFDebugLoclists>(
DWARFDataExtractor(Context.getDWARFObj(),
Context.getDWARFObj().getLoclistsSection(),
- isLittleEndian, getAddressByteSize()),
+ IsLittleEndian, getAddressByteSize()),
getVersion());
} else {
LocTable = std::make_unique<DWARFDebugLoc>(DWARFDataExtractor(
Context.getDWARFObj(), Context.getDWARFObj().getLocSection(),
- isLittleEndian, getAddressByteSize()));
+ IsLittleEndian, getAddressByteSize()));
}
// Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for
@@ -650,7 +650,7 @@ DWARFUnit::findRnglistFromOffset(uint64_t Offset) {
return RangeList.getAbsoluteRanges(getBaseAddress());
}
DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection,
- isLittleEndian, Header.getAddressByteSize());
+ IsLittleEndian, Header.getAddressByteSize());
DWARFDebugRnglistTable RnglistTable;
auto RangeListOrError = RnglistTable.findList(RangesData, Offset);
if (RangeListOrError)
@@ -1175,10 +1175,10 @@ DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor & DA) {
}
Optional<uint64_t> DWARFUnit::getRnglistOffset(uint32_t Index) {
- DataExtractor RangesData(RangeSection->Data, isLittleEndian,
+ DataExtractor RangesData(RangeSection->Data, IsLittleEndian,
getAddressByteSize());
DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
- isLittleEndian, 0);
+ IsLittleEndian, 0);
if (Optional<uint64_t> Off = llvm::DWARFListTableHeader::getOffsetEntry(
RangesData, RangeSectionBase, getFormat(), Index))
return *Off + RangeSectionBase;
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index d0db3fed0552a..3f113d65c9bfc 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -1109,6 +1109,7 @@ TEST(DWARFDebugInfo, TestStringOffsets) {
DWARFUnit *U = DwarfContext->getUnitAtIndex(0);
auto DieDG = U->getUnitDIE(false);
ASSERT_TRUE(DieDG.isValid());
+ ASSERT_TRUE(U->isLittleEndian() == Triple.isLittleEndian());
// Now make sure the string offsets came out properly. Attr2 should have index
// 0 (because it was the first indexed string) even though the string itself
More information about the llvm-commits
mailing list