Skip to content

Commit 5d24341

Browse files
[lld] Migrate away from PointerUnion::dyn_cast (NFC) (llvm#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.
1 parent 4075915 commit 5d24341

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lld/MachO/ObjC.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ ObjcCategoryMerger::tryGetSymbolAtIsecOffset(const ConcatInputSection *isec,
543543
if (!reloc)
544544
return nullptr;
545545

546-
Symbol *sym = reloc->referent.dyn_cast<Symbol *>();
546+
Symbol *sym = dyn_cast_if_present<Symbol *>(reloc->referent);
547547

548548
if (reloc->addend && sym) {
549549
assert(isa<Defined>(sym) && "Expected defined for non-zero addend");

lld/MachO/Writer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ void Writer::scanRelocations() {
711711

712712
// Canonicalize the referent so that later accesses in Writer won't
713713
// have to worry about it.
714-
if (auto *referentIsec = r.referent.dyn_cast<InputSection *>())
714+
if (auto *referentIsec = dyn_cast_if_present<InputSection *>(r.referent))
715715
r.referent = referentIsec->canonical();
716716

717717
if (target->hasAttr(r.type, RelocAttrBits::SUBTRAHEND)) {
@@ -725,7 +725,7 @@ void Writer::scanRelocations() {
725725
it->referent = referentIsec->canonical();
726726
continue;
727727
}
728-
if (auto *sym = r.referent.dyn_cast<Symbol *>()) {
728+
if (auto *sym = dyn_cast_if_present<Symbol *>(r.referent)) {
729729
if (auto *undefined = dyn_cast<Undefined>(sym))
730730
treatUndefinedSymbol(*undefined, isec, r.offset);
731731
// treatUndefinedSymbol() can replace sym with a DylibSymbol; re-check.

0 commit comments

Comments
 (0)