[llvm] 96e3876 - [AsmPrinter] Migrate away from PointerUnion::dyn_cast (NFC) (#135740)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 15 02:36:22 PDT 2025
Author: Kazu Hirata
Date: 2025-04-15T02:36:18-07:00
New Revision: 96e38766118c62ed42ddedd4642284cdca12904e
URL: https://github.com/llvm/llvm-project/commit/96e38766118c62ed42ddedd4642284cdca12904e
DIFF: https://github.com/llvm/llvm-project/commit/96e38766118c62ed42ddedd4642284cdca12904e.diff
LOG: [AsmPrinter] Migrate away from PointerUnion::dyn_cast (NFC) (#135740)
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>
We use dyn_cast_if_present here because Bound can be null.
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 2723b1f55ccaa..bf166cbb043de 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1481,16 +1481,16 @@ void DwarfUnit::constructSubrangeDIE(DIE &DW_Subrange, const DISubrangeType *SR,
auto AddBoundTypeEntry = [&](dwarf::Attribute Attr,
DISubrangeType::BoundType Bound) -> void {
- if (auto *BV = Bound.dyn_cast<DIVariable *>()) {
+ if (auto *BV = dyn_cast_if_present<DIVariable *>(Bound)) {
if (auto *VarDIE = getDIE(BV))
addDIEEntry(DW_Subrange, Attr, *VarDIE);
- } else if (auto *BE = Bound.dyn_cast<DIExpression *>()) {
+ } else if (auto *BE = dyn_cast_if_present<DIExpression *>(Bound)) {
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
DIEDwarfExpression DwarfExpr(*Asm, getCU(), *Loc);
DwarfExpr.setMemoryLocationKind();
DwarfExpr.addExpression(BE);
addBlock(DW_Subrange, Attr, DwarfExpr.finalize());
- } else if (auto *BI = Bound.dyn_cast<ConstantInt *>()) {
+ } else if (auto *BI = dyn_cast_if_present<ConstantInt *>(Bound)) {
if (Attr == dwarf::DW_AT_GNU_bias) {
if (BI->getSExtValue() != 0)
addUInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
More information about the llvm-commits
mailing list