[lld] a0ec385 - [lld] Migrate away from PointerUnion::dyn_cast (NFC) (#123721)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 21 11:57:57 PST 2025


Author: Kazu Hirata
Date: 2025-01-21T11:57:53-08:00
New Revision: a0ec385873dfe96bc5f286a3b13d83c598ee37da

URL: https://github.com/llvm/llvm-project/commit/a0ec385873dfe96bc5f286a3b13d83c598ee37da
DIFF: https://github.com/llvm/llvm-project/commit/a0ec385873dfe96bc5f286a3b13d83c598ee37da.diff

LOG: [lld] Migrate away from PointerUnion::dyn_cast (NFC) (#123721)

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>

Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses cast
because we know expect isa<InputSection *>(reloc.referent) to be true.

Added: 
    

Modified: 
    lld/MachO/Arch/ARM64.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/Arch/ARM64.cpp b/lld/MachO/Arch/ARM64.cpp
index bf458e392be8fb..2f3ca13b832a11 100644
--- a/lld/MachO/Arch/ARM64.cpp
+++ b/lld/MachO/Arch/ARM64.cpp
@@ -205,7 +205,7 @@ InputSection *ARM64::getThunkBranchTarget(InputSection *thunk) const {
   assert(isa<InputSection *>(reloc.referent) &&
          "ARM64 thunk reloc is expected to point to an InputSection");
 
-  return reloc.referent.dyn_cast<InputSection *>();
+  return cast<InputSection *>(reloc.referent);
 }
 
 uint32_t ARM64::getICFSafeThunkSize() const { return sizeof(icfSafeThunkCode); }


        


More information about the llvm-commits mailing list