Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb] Migrate away from PointerUnion::{is,get} (NFC) #122420

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class ELFRelocation {

static elf_sxword RelocAddend64(const ELFRelocation &rel);

bool IsRela() { return (reloc.is<ELFRela *>()); }
bool IsRela() { return (llvm::isa<ELFRela *>(reloc)); }

private:
typedef llvm::PointerUnion<ELFRel *, ELFRela *> RelocUnion;
Expand All @@ -144,74 +144,74 @@ ELFRelocation::ELFRelocation(unsigned type) {
}

ELFRelocation::~ELFRelocation() {
if (reloc.is<ELFRel *>())
delete reloc.get<ELFRel *>();
if (auto *elfrel = llvm::dyn_cast<ELFRel *>(reloc))
delete elfrel;
else
delete reloc.get<ELFRela *>();
delete llvm::cast<ELFRela *>(reloc);
}

bool ELFRelocation::Parse(const lldb_private::DataExtractor &data,
lldb::offset_t *offset) {
if (reloc.is<ELFRel *>())
return reloc.get<ELFRel *>()->Parse(data, offset);
if (auto *elfrel = llvm::dyn_cast<ELFRel *>(reloc))
return elfrel->Parse(data, offset);
else
return reloc.get<ELFRela *>()->Parse(data, offset);
return llvm::cast<ELFRela *>(reloc)->Parse(data, offset);
}

unsigned ELFRelocation::RelocType32(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
return ELFRel::RelocType32(*rel.reloc.get<ELFRel *>());
if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
return ELFRel::RelocType32(*elfrel);
else
return ELFRela::RelocType32(*rel.reloc.get<ELFRela *>());
return ELFRela::RelocType32(*llvm::cast<ELFRela *>(rel.reloc));
}

unsigned ELFRelocation::RelocType64(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
return ELFRel::RelocType64(*rel.reloc.get<ELFRel *>());
if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
return ELFRel::RelocType64(*elfrel);
else
return ELFRela::RelocType64(*rel.reloc.get<ELFRela *>());
return ELFRela::RelocType64(*llvm::cast<ELFRela *>(rel.reloc));
}

unsigned ELFRelocation::RelocSymbol32(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
return ELFRel::RelocSymbol32(*rel.reloc.get<ELFRel *>());
if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
return ELFRel::RelocSymbol32(*elfrel);
else
return ELFRela::RelocSymbol32(*rel.reloc.get<ELFRela *>());
return ELFRela::RelocSymbol32(*llvm::cast<ELFRela *>(rel.reloc));
}

unsigned ELFRelocation::RelocSymbol64(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
return ELFRel::RelocSymbol64(*rel.reloc.get<ELFRel *>());
if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
return ELFRel::RelocSymbol64(*elfrel);
else
return ELFRela::RelocSymbol64(*rel.reloc.get<ELFRela *>());
return ELFRela::RelocSymbol64(*llvm::cast<ELFRela *>(rel.reloc));
}

elf_addr ELFRelocation::RelocOffset32(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
return rel.reloc.get<ELFRel *>()->r_offset;
if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
return elfrel->r_offset;
else
return rel.reloc.get<ELFRela *>()->r_offset;
return llvm::cast<ELFRela *>(rel.reloc)->r_offset;
}

elf_addr ELFRelocation::RelocOffset64(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
return rel.reloc.get<ELFRel *>()->r_offset;
if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
return elfrel->r_offset;
else
return rel.reloc.get<ELFRela *>()->r_offset;
return llvm::cast<ELFRela *>(rel.reloc)->r_offset;
}

elf_sxword ELFRelocation::RelocAddend32(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
if (llvm::isa<ELFRel *>(rel.reloc))
return 0;
else
return rel.reloc.get<ELFRela *>()->r_addend;
return llvm::cast<ELFRela *>(rel.reloc)->r_addend;
}

elf_sxword ELFRelocation::RelocAddend64(const ELFRelocation &rel) {
if (rel.reloc.is<ELFRel *>())
if (llvm::isa<ELFRel *>(rel.reloc))
return 0;
else
return rel.reloc.get<ELFRela *>()->r_addend;
return llvm::cast<ELFRela *>(rel.reloc)->r_addend;
}

static user_id_t SegmentID(size_t PHdrIndex) {
Expand Down
Loading