diff options
| author | Felipe de Azevedo Piovezan <fpiovezan@apple.com> | 2024-01-08 17:04:07 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-08 17:04:07 -0300 |
| commit | e72c71671e044aa30ca35bed9e20da771ae216b5 (patch) | |
| tree | be2964544ed89276fdd64b617e597ce6c49aa0c2 /llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp | |
| parent | eea627e3e3c423149cd2cd46cb6309b8d303e8bd (diff) | |
[AccelTable][nfc] Add helper function to cast AccelTableData (#77100)
Specializations of AccelTableBase are always interested in accessing the
derived versions of their data classes (e.g. DWARF5AccelTableData). They
do so by sprinkling `static_casts` all over the code.
This commit adds a helper function to simplify this process, reducinng
the number of casts that have to be made in the middle of code, making
it easier to read.
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp index bf580269eca6..b72c17aa6f54 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp @@ -342,8 +342,8 @@ void AppleAccelTableWriter::emitData() const { Asm->emitDwarfStringOffset(Hash->Name); Asm->OutStreamer->AddComment("Num DIEs"); Asm->emitInt32(Hash->Values.size()); - for (const auto *V : Hash->Values) - static_cast<const AppleAccelTableData *>(V)->emit(Asm); + for (const auto *V : Hash->getValues<const AppleAccelTableData *>()) + V->emit(Asm); PrevHash = Hash->HashValue; } // Emit the final end marker for the bucket. @@ -415,11 +415,10 @@ static uint32_t constructAbbreviationTag( void Dwarf5AccelTableWriter::populateAbbrevsMap() { for (auto &Bucket : Contents.getBuckets()) { for (auto *Hash : Bucket) { - for (auto *Value : Hash->Values) { + for (auto *Value : Hash->getValues<DWARF5AccelTableData *>()) { std::optional<DWARF5AccelTable::UnitIndexAndEncoding> EntryRet = - getIndexForEntry(*static_cast<const DWARF5AccelTableData *>(Value)); - unsigned Tag = - static_cast<const DWARF5AccelTableData *>(Value)->getDieTag(); + getIndexForEntry(*Value); + unsigned Tag = Value->getDieTag(); uint32_t AbbrvTag = constructAbbreviationTag(Tag, EntryRet); if (Abbreviations.count(AbbrvTag) == 0) { SmallVector<DWARF5AccelTableData::AttributeEncoding, 2> UA; |
