Skip to content

Commit 636de2b

Browse files
Change isLittleEndian to follow llvm style and add an accessor
Differential Revision: https://reviews.llvm.org/D134290
1 parent bb4c53b commit 636de2b

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class DWARFUnit {
224224
const DWARFSection *AddrOffsetSection;
225225
DWARFUnit *SU;
226226
Optional<uint64_t> AddrOffsetSectionBase;
227-
bool isLittleEndian;
227+
bool IsLittleEndian;
228228
bool IsDWO;
229229
const DWARFUnitVector &UnitVector;
230230

@@ -307,6 +307,7 @@ class DWARFUnit {
307307

308308
virtual ~DWARFUnit();
309309

310+
bool isLittleEndian() const { return IsLittleEndian; }
310311
bool isDWOUnit() const { return IsDWO; }
311312
DWARFContext& getContext() const { return Context; }
312313
const DWARFSection &getInfoSection() const { return InfoSection; }

llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,15 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
192192
bool IsDWO, const DWARFUnitVector &UnitVector)
193193
: Context(DC), InfoSection(Section), Header(Header), Abbrev(DA),
194194
RangeSection(RS), LineSection(LS), StringSection(SS),
195-
StringOffsetSection(SOS), AddrOffsetSection(AOS), isLittleEndian(LE),
195+
StringOffsetSection(SOS), AddrOffsetSection(AOS), IsLittleEndian(LE),
196196
IsDWO(IsDWO), UnitVector(UnitVector) {
197197
clear();
198198
}
199199

200200
DWARFUnit::~DWARFUnit() = default;
201201

202202
DWARFDataExtractor DWARFUnit::getDebugInfoExtractor() const {
203-
return DWARFDataExtractor(Context.getDWARFObj(), InfoSection, isLittleEndian,
203+
return DWARFDataExtractor(Context.getDWARFObj(), InfoSection, IsLittleEndian,
204204
getAddressByteSize());
205205
}
206206

@@ -222,7 +222,7 @@ DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const {
222222
if (AddrOffsetSection->Data.size() < Offset + getAddressByteSize())
223223
return None;
224224
DWARFDataExtractor DA(Context.getDWARFObj(), *AddrOffsetSection,
225-
isLittleEndian, getAddressByteSize());
225+
IsLittleEndian, getAddressByteSize());
226226
uint64_t Section;
227227
uint64_t Address = DA.getRelocatedAddress(&Offset, &Section);
228228
return {{Address, Section}};
@@ -240,7 +240,7 @@ Expected<uint64_t> DWARFUnit::getStringOffsetSectionItem(uint32_t Index) const {
240240
", which is too large",
241241
inconvertibleErrorCode());
242242
DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection,
243-
isLittleEndian, 0);
243+
IsLittleEndian, 0);
244244
return DA.getRelocatedValue(ItemSize, &Offset);
245245
}
246246

@@ -367,7 +367,7 @@ Error DWARFUnit::extractRangeList(uint64_t RangeListOffset,
367367
// Require that compile unit is extracted.
368368
assert(!DieArray.empty());
369369
DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection,
370-
isLittleEndian, getAddressByteSize());
370+
IsLittleEndian, getAddressByteSize());
371371
uint64_t ActualRangeListOffset = RangeSectionBase + RangeListOffset;
372372
return RangeList.extract(RangesData, &ActualRangeListOffset);
373373
}
@@ -521,7 +521,7 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
521521
// In both cases we need to determine the format of the contribution,
522522
// which may differ from the unit's format.
523523
DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection,
524-
isLittleEndian, 0);
524+
IsLittleEndian, 0);
525525
if (IsDWO || getVersion() >= 5) {
526526
auto StringOffsetOrError =
527527
IsDWO ? determineStringOffsetsTableContributionDWO(DA)
@@ -566,20 +566,20 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
566566
Header.getVersion() >= 5 ? DW_SECT_LOCLISTS : DW_SECT_EXT_LOC))
567567
Data = Data.substr(C->Offset, C->Length);
568568

569-
DWARFDataExtractor DWARFData(Data, isLittleEndian, getAddressByteSize());
569+
DWARFDataExtractor DWARFData(Data, IsLittleEndian, getAddressByteSize());
570570
LocTable =
571571
std::make_unique<DWARFDebugLoclists>(DWARFData, Header.getVersion());
572572
LocSectionBase = DWARFListTableHeader::getHeaderSize(Header.getFormat());
573573
} else if (getVersion() >= 5) {
574574
LocTable = std::make_unique<DWARFDebugLoclists>(
575575
DWARFDataExtractor(Context.getDWARFObj(),
576576
Context.getDWARFObj().getLoclistsSection(),
577-
isLittleEndian, getAddressByteSize()),
577+
IsLittleEndian, getAddressByteSize()),
578578
getVersion());
579579
} else {
580580
LocTable = std::make_unique<DWARFDebugLoc>(DWARFDataExtractor(
581581
Context.getDWARFObj(), Context.getDWARFObj().getLocSection(),
582-
isLittleEndian, getAddressByteSize()));
582+
IsLittleEndian, getAddressByteSize()));
583583
}
584584

585585
// Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for
@@ -650,7 +650,7 @@ DWARFUnit::findRnglistFromOffset(uint64_t Offset) {
650650
return RangeList.getAbsoluteRanges(getBaseAddress());
651651
}
652652
DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection,
653-
isLittleEndian, Header.getAddressByteSize());
653+
IsLittleEndian, Header.getAddressByteSize());
654654
DWARFDebugRnglistTable RnglistTable;
655655
auto RangeListOrError = RnglistTable.findList(RangesData, Offset);
656656
if (RangeListOrError)
@@ -1175,10 +1175,10 @@ DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor & DA) {
11751175
}
11761176

11771177
Optional<uint64_t> DWARFUnit::getRnglistOffset(uint32_t Index) {
1178-
DataExtractor RangesData(RangeSection->Data, isLittleEndian,
1178+
DataExtractor RangesData(RangeSection->Data, IsLittleEndian,
11791179
getAddressByteSize());
11801180
DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
1181-
isLittleEndian, 0);
1181+
IsLittleEndian, 0);
11821182
if (Optional<uint64_t> Off = llvm::DWARFListTableHeader::getOffsetEntry(
11831183
RangesData, RangeSectionBase, getFormat(), Index))
11841184
return *Off + RangeSectionBase;

llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@ TEST(DWARFDebugInfo, TestStringOffsets) {
11091109
DWARFUnit *U = DwarfContext->getUnitAtIndex(0);
11101110
auto DieDG = U->getUnitDIE(false);
11111111
ASSERT_TRUE(DieDG.isValid());
1112+
ASSERT_TRUE(U->isLittleEndian() == Triple.isLittleEndian());
11121113

11131114
// Now make sure the string offsets came out properly. Attr2 should have index
11141115
// 0 (because it was the first indexed string) even though the string itself

0 commit comments

Comments
 (0)