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

Note that PointerUnion::{is,get} have been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //        isa<T>, cast<T> and the llvm::dyn_cast<T>

I'm not touching PointerUnion::dyn_cast for now because it's a bit
complicated; we could blindly migrate it to dyn_cast_if_present, but
we should probably use dyn_cast when the operand is known to be
non-null.
This commit is contained in:
Kazu Hirata
2024-12-14 20:07:08 -08:00
committed by GitHub
parent 8c681a929b
commit e04fde193b
11 changed files with 35 additions and 35 deletions

View File

@@ -226,13 +226,13 @@ void ConcatInputSection::writeTo(uint8_t *buf) {
const bool needsFixup = config->emitChainedFixups &&
target->hasAttr(r.type, RelocAttrBits::UNSIGNED);
if (target->hasAttr(r.type, RelocAttrBits::SUBTRAHEND)) {
const Symbol *fromSym = r.referent.get<Symbol *>();
const Symbol *fromSym = cast<Symbol *>(r.referent);
const Reloc &minuend = relocs[++i];
uint64_t minuendVA;
if (const Symbol *toSym = minuend.referent.dyn_cast<Symbol *>())
minuendVA = toSym->getVA() + minuend.addend;
else {
auto *referentIsec = minuend.referent.get<InputSection *>();
auto *referentIsec = cast<InputSection *>(minuend.referent);
assert(!::shouldOmitFromOutput(referentIsec));
minuendVA = referentIsec->getVA(minuend.addend);
}