Skip to content

Commit 0ab165c

Browse files
authored
[DebugInfo] Remove unused argument of DataExtractor constructor (NFC) (#191968)
`AddressSize` parameter is not used by `DataExtractor` and will be removed in the future. See #190519 for more context. As a drive-by change, use the constructor accepting ArrayRef where it allows removing extra casts.
1 parent 6a02dc5 commit 0ab165c

16 files changed

Lines changed: 47 additions & 58 deletions

llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,13 @@ class LLVM_ABI DWARFContext : public DIContext {
357357
void clearLineTableForUnit(DWARFUnit *U);
358358

359359
DataExtractor getStringExtractor() const {
360-
return DataExtractor(DObj->getStrSection(), false, 0);
360+
return DataExtractor(DObj->getStrSection(), false);
361361
}
362362
DataExtractor getStringDWOExtractor() const {
363-
return DataExtractor(DObj->getStrDWOSection(), false, 0);
363+
return DataExtractor(DObj->getStrDWOSection(), false);
364364
}
365365
DataExtractor getLineStringExtractor() const {
366-
return DataExtractor(DObj->getLineStrSection(), false, 0);
366+
return DataExtractor(DObj->getLineStrSection(), false);
367367
}
368368

369369
/// Wraps the returned DIEs for a given address.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ class LLVM_ABI DWARFUnit {
395395
DWARFDataExtractor getDebugInfoExtractor() const;
396396

397397
DataExtractor getStringExtractor() const {
398-
return DataExtractor(StringSection, false, 0);
398+
return DataExtractor(StringSection, false);
399399
}
400400

401401
const DWARFLocationTable &getLocationTable() { return *LocTable; }

llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFCFIProgram.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ class CFIProgram {
189189
addInstruction(Opcode, 0);
190190
StringRef Expression = Data.getBytes(C, ExprLength);
191191

192-
DataExtractor Extractor(Expression, Data.isLittleEndian(),
193-
Data.getAddressSize());
192+
DataExtractor Extractor(Expression, Data.isLittleEndian());
194193
// Note. We do not pass the DWARF format to DWARFExpression, because
195194
// DW_OP_call_ref, the only operation which depends on the format, is
196195
// prohibited in call frame instructions, see sec. 6.4.2 in DWARFv5.
@@ -205,8 +204,7 @@ class CFIProgram {
205204

206205
uint64_t BlockLength = Data.getULEB128(C);
207206
StringRef Expression = Data.getBytes(C, BlockLength);
208-
DataExtractor Extractor(Expression, Data.isLittleEndian(),
209-
Data.getAddressSize());
207+
DataExtractor Extractor(Expression, Data.isLittleEndian());
210208
// Note. We do not pass the DWARF format to DWARFExpression, because
211209
// DW_OP_call_ref, the only operation which depends on the format, is
212210
// prohibited in call frame instructions, see sec. 6.4.2 in DWARFv5.

llvm/lib/DebugInfo/BTF/BTFParser.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ struct BTFParser::ParseContext {
8989
Expected<StringRef> Contents = Sec.getContents();
9090
if (!Contents)
9191
return Contents.takeError();
92-
return DataExtractor(Contents.get(), Obj.isLittleEndian(),
93-
Obj.getBytesInAddress());
92+
return DataExtractor(Contents.get(), Obj.isLittleEndian());
9493
}
9594

9695
std::optional<SectionRef> findSection(StringRef Name) const {

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static T &getAccelTable(std::unique_ptr<T> &Cache, const DWARFObject &Obj,
196196
if (Cache)
197197
return *Cache;
198198
DWARFDataExtractor AccelSection(Obj, Section, IsLittleEndian, 0);
199-
DataExtractor StrData(StringSection, IsLittleEndian, 0);
199+
DataExtractor StrData(StringSection, IsLittleEndian);
200200
Cache = std::make_unique<T>(AccelSection, StrData);
201201
if (Error E = Cache->extract())
202202
llvm::consumeError(std::move(E));
@@ -320,7 +320,7 @@ class ThreadUnsafeDWARFContextState : public DWARFContext::DWARFContextState {
320320
if (AbbrevDWO)
321321
return AbbrevDWO.get();
322322
const DWARFObject &DObj = D.getDWARFObj();
323-
DataExtractor abbrData(DObj.getAbbrevDWOSection(), D.isLittleEndian(), 0);
323+
DataExtractor abbrData(DObj.getAbbrevDWOSection(), D.isLittleEndian());
324324
AbbrevDWO = std::make_unique<DWARFDebugAbbrev>(abbrData);
325325
return AbbrevDWO.get();
326326
}
@@ -329,8 +329,7 @@ class ThreadUnsafeDWARFContextState : public DWARFContext::DWARFContextState {
329329
if (CUIndex)
330330
return *CUIndex;
331331

332-
DataExtractor Data(D.getDWARFObj().getCUIndexSection(),
333-
D.isLittleEndian(), 0);
332+
DataExtractor Data(D.getDWARFObj().getCUIndexSection(), D.isLittleEndian());
334333
CUIndex = std::make_unique<DWARFUnitIndex>(DW_SECT_INFO);
335334
if (CUIndex->parse(Data))
336335
fixupIndex(D, *CUIndex);
@@ -340,8 +339,7 @@ class ThreadUnsafeDWARFContextState : public DWARFContext::DWARFContextState {
340339
if (TUIndex)
341340
return *TUIndex;
342341

343-
DataExtractor Data(D.getDWARFObj().getTUIndexSection(),
344-
D.isLittleEndian(), 0);
342+
DataExtractor Data(D.getDWARFObj().getTUIndexSection(), D.isLittleEndian());
345343
TUIndex = std::make_unique<DWARFUnitIndex>(DW_SECT_EXT_TYPES);
346344
bool isParseSuccessful = TUIndex->parse(Data);
347345
// If we are parsing TU-index and for .debug_types section we don't need
@@ -355,7 +353,8 @@ class ThreadUnsafeDWARFContextState : public DWARFContext::DWARFContextState {
355353
if (GdbIndex)
356354
return *GdbIndex;
357355

358-
DataExtractor Data(D.getDWARFObj().getGdbIndexSection(), true /*LE*/, 0);
356+
DataExtractor Data(D.getDWARFObj().getGdbIndexSection(),
357+
/*IsLittleEndian=*/true);
359358
GdbIndex = std::make_unique<DWARFGdbIndex>();
360359
GdbIndex->parse(Data);
361360
return *GdbIndex;
@@ -365,8 +364,7 @@ class ThreadUnsafeDWARFContextState : public DWARFContext::DWARFContextState {
365364
if (Abbrev)
366365
return Abbrev.get();
367366

368-
DataExtractor Data(D.getDWARFObj().getAbbrevSection(),
369-
D.isLittleEndian(), 0);
367+
DataExtractor Data(D.getDWARFObj().getAbbrevSection(), D.isLittleEndian());
370368
Abbrev = std::make_unique<DWARFDebugAbbrev>(Data);
371369
return Abbrev.get();
372370
}
@@ -834,7 +832,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
834832
bool LittleEndian) {
835833
auto Contributions = collectContributionData(Units);
836834
DWARFDataExtractor StrOffsetExt(Obj, StringOffsetsSection, LittleEndian, 0);
837-
DataExtractor StrData(StringSection, LittleEndian, 0);
835+
DataExtractor StrData(StringSection, LittleEndian);
838836
uint64_t SectionSize = StringOffsetsSection.Data.size();
839837
uint64_t Offset = 0;
840838
for (auto &Contribution : Contributions) {
@@ -1176,7 +1174,7 @@ void DWARFContext::dump(
11761174
};
11771175

11781176
auto DumpStrSection = [&](StringRef Section) {
1179-
DataExtractor StrData(Section, isLittleEndian(), 0);
1177+
DataExtractor StrData(Section, isLittleEndian());
11801178
uint64_t Offset = 0;
11811179
uint64_t StrOffset = 0;
11821180
while (StrData.isValidOffset(Offset)) {

llvm/lib/DebugInfo/DWARF/DWARFDie.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ static void dumpLocationExpr(raw_ostream &OS, const DWARFFormValue &FormValue,
9696
"bad FORM for location expression");
9797
DWARFContext &Ctx = U->getContext();
9898
ArrayRef<uint8_t> Expr = *FormValue.getAsBlock();
99-
DataExtractor Data(StringRef((const char *)Expr.data(), Expr.size()),
100-
Ctx.isLittleEndian(), 0);
99+
DataExtractor Data(Expr, Ctx.isLittleEndian());
101100
DWARFExpression DE(Data, U->getAddressByteSize(), U->getFormParams().Format);
102101
printDwarfExpression(&DE, OS, DumpOpts, U);
103102
}

llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ void DWARFUnit::updateVariableDieMap(DWARFDie Die) {
803803

804804
for (const DWARFLocationExpression &Location : *Locations) {
805805
uint8_t AddressSize = getAddressByteSize();
806-
DataExtractor Data(Location.Expr, isLittleEndian(), AddressSize);
806+
DataExtractor Data(Location.Expr, isLittleEndian());
807807
DWARFExpression Expr(Data, AddressSize);
808808
auto It = Expr.begin();
809809
if (It == Expr.end())
@@ -1219,8 +1219,7 @@ DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA) {
12191219
}
12201220

12211221
std::optional<uint64_t> DWARFUnit::getRnglistOffset(uint32_t Index) {
1222-
DataExtractor RangesData(RangeSection->Data, IsLittleEndian,
1223-
getAddressByteSize());
1222+
DataExtractor RangesData(RangeSection->Data, IsLittleEndian);
12241223
DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
12251224
IsLittleEndian, 0);
12261225
if (std::optional<uint64_t> Off = llvm::DWARFListTableHeader::getOffsetEntry(

llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ unsigned DWARFVerifier::verifyIndex(StringRef Name,
500500
return 0;
501501
OS << "Verifying " << Name << "...\n";
502502
DWARFUnitIndex Index(InfoColumnKind);
503-
DataExtractor D(IndexStr, DCtx.isLittleEndian(), 0);
503+
DataExtractor D(IndexStr, DCtx.isLittleEndian());
504504
if (!Index.parse(D))
505505
return 1;
506506
using MapType = IntervalMap<uint64_t, uint64_t>;
@@ -771,7 +771,7 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die,
771771
if (Expected<std::vector<DWARFLocationExpression>> Loc =
772772
Die.getLocations(DW_AT_location)) {
773773
for (const auto &Entry : *Loc) {
774-
DataExtractor Data(toStringRef(Entry.Expr), DCtx.isLittleEndian(), 0);
774+
DataExtractor Data(Entry.Expr, DCtx.isLittleEndian());
775775
DWARFExpression Expression(Data, U->getAddressByteSize(),
776776
U->getFormParams().Format);
777777
bool Error =
@@ -1913,8 +1913,7 @@ static bool isVariableIndexable(const DWARFDie &Die, DWARFContext &DCtx) {
19131913
}
19141914
DWARFUnit *U = Die.getDwarfUnit();
19151915
for (const auto &Entry : *Loc) {
1916-
DataExtractor Data(toStringRef(Entry.Expr), DCtx.isLittleEndian(),
1917-
U->getAddressByteSize());
1916+
DataExtractor Data(Entry.Expr, DCtx.isLittleEndian());
19181917
DWARFExpression Expression(Data, U->getAddressByteSize(),
19191918
U->getFormParams().Format);
19201919
bool IsInteresting =
@@ -2184,7 +2183,7 @@ void DWARFVerifier::verifyDebugNames(const DWARFSection &AccelSection,
21842183

21852184
bool DWARFVerifier::handleAccelTables() {
21862185
const DWARFObject &D = DCtx.getDWARFObj();
2187-
DataExtractor StrData(D.getStrSection(), DCtx.isLittleEndian(), 0);
2186+
DataExtractor StrData(D.getStrSection(), DCtx.isLittleEndian());
21882187
if (!D.getAppleNamesSection().Data.empty())
21892188
verifyAppleAccelTable(&D.getAppleNamesSection(), &StrData, ".apple_names");
21902189
if (!D.getAppleTypesSection().Data.empty())

llvm/lib/DebugInfo/GSYM/ObjectFileTransformer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static std::vector<uint8_t> getUUID(const object::ObjectFile &Obj) {
4747
consumeError(E.takeError());
4848
continue;
4949
}
50-
DataExtractor Decoder(BuildIDData, Obj.makeTriple().isLittleEndian(), 8);
50+
DataExtractor Decoder(BuildIDData, Obj.makeTriple().isLittleEndian());
5151
uint64_t Offset = 0;
5252
const uint32_t NameSize = Decoder.getU32(&Offset);
5353
const uint32_t PayloadSize = Decoder.getU32(&Offset);

llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,7 @@ void LVDWARFReader::processLocationList(dwarf::Attribute Attr,
805805
(DWARFAttribute::mayHaveLocationExpr(Attr) &&
806806
FormValue.isFormClass(DWARFFormValue::FC_Exprloc))) {
807807
ArrayRef<uint8_t> Expr = *FormValue.getAsBlock();
808-
DataExtractor Data(StringRef((const char *)Expr.data(), Expr.size()),
809-
IsLittleEndian, 0);
808+
DataExtractor Data(Expr, IsLittleEndian);
810809
DWARFExpression Expression(Data, U->getAddressByteSize(),
811810
U->getFormParams().Format);
812811

0 commit comments

Comments
 (0)