mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-21 15:47:14 +00:00
[lld] Migrate away from PointerUnion::dyn_cast (NFC) (#124504)
Note that PointerUnion::dyn_cast has 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> This patch migrates uses of PointerUnion::dyn_cast to dyn_cast_if_present (see the definition of PointerUnion::dyn_cast). Note that we cannot use dyn_cast in any of the migrations in this patch; placing assert(!X.isNull()); just before any of dyn_cast_if_present in this patch triggers some failure in check-lld.
This commit is contained in:
parent
4075915ebd
commit
5d24341667
lld/MachO
@ -543,7 +543,7 @@ ObjcCategoryMerger::tryGetSymbolAtIsecOffset(const ConcatInputSection *isec,
|
||||
if (!reloc)
|
||||
return nullptr;
|
||||
|
||||
Symbol *sym = reloc->referent.dyn_cast<Symbol *>();
|
||||
Symbol *sym = dyn_cast_if_present<Symbol *>(reloc->referent);
|
||||
|
||||
if (reloc->addend && sym) {
|
||||
assert(isa<Defined>(sym) && "Expected defined for non-zero addend");
|
||||
|
@ -711,7 +711,7 @@ void Writer::scanRelocations() {
|
||||
|
||||
// Canonicalize the referent so that later accesses in Writer won't
|
||||
// have to worry about it.
|
||||
if (auto *referentIsec = r.referent.dyn_cast<InputSection *>())
|
||||
if (auto *referentIsec = dyn_cast_if_present<InputSection *>(r.referent))
|
||||
r.referent = referentIsec->canonical();
|
||||
|
||||
if (target->hasAttr(r.type, RelocAttrBits::SUBTRAHEND)) {
|
||||
@ -725,7 +725,7 @@ void Writer::scanRelocations() {
|
||||
it->referent = referentIsec->canonical();
|
||||
continue;
|
||||
}
|
||||
if (auto *sym = r.referent.dyn_cast<Symbol *>()) {
|
||||
if (auto *sym = dyn_cast_if_present<Symbol *>(r.referent)) {
|
||||
if (auto *undefined = dyn_cast<Undefined>(sym))
|
||||
treatUndefinedSymbol(*undefined, isec, r.offset);
|
||||
// treatUndefinedSymbol() can replace sym with a DylibSymbol; re-check.
|
||||
|
Loading…
x
Reference in New Issue
Block a user