From 5d9efb640d037bc9dc6c1f7aa2fd5c505952921e Mon Sep 17 00:00:00 2001 From: Abid Qadeer Date: Fri, 20 Dec 2024 18:38:50 +0000 Subject: [PATCH] [flang][NFC] Replace dyn_cast_or_null with dyn_cast_if_present. --- .../Transforms/DebugTypeGenerator.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp index cc99698ead33f..2aef913d9df94 100644 --- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp +++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp @@ -325,7 +325,7 @@ static bool canCacheThisType(mlir::LLVM::DICompositeTypeAttr comTy) { std::pair DebugTypeGenerator::getFieldSizeAndAlign(mlir::Type fieldTy) { mlir::Type llvmTy; - if (auto boxTy = mlir::dyn_cast_or_null(fieldTy)) + if (auto boxTy = mlir::dyn_cast_if_present(fieldTy)) llvmTy = llvmTypeConverter.convertBoxTypeAsStruct(boxTy, getBoxRank(boxTy)); else llvmTy = llvmTypeConverter.convertType(fieldTy); @@ -371,7 +371,7 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType( std::optional> lowerBounds = fir::getComponentLowerBoundsIfNonDefault(Ty, fieldName, module, symbolTable); - auto seqTy = mlir::dyn_cast_or_null(fieldTy); + auto seqTy = mlir::dyn_cast_if_present(fieldTy); // For members of the derived types, the information about the shift in // lower bounds is not part of the declOp but has to be extracted from the @@ -622,10 +622,10 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertPointerLikeType( // Arrays and character need different treatment because DWARF have special // constructs for them to get the location from the descriptor. Rest of // types are handled like pointer to underlying type. - if (auto seqTy = mlir::dyn_cast_or_null(elTy)) + if (auto seqTy = mlir::dyn_cast_if_present(elTy)) return convertBoxedSequenceType(seqTy, fileAttr, scope, declOp, genAllocated, genAssociated); - if (auto charTy = mlir::dyn_cast_or_null(elTy)) + if (auto charTy = mlir::dyn_cast_if_present(elTy)) return convertCharacterType(charTy, fileAttr, scope, declOp, /*hasDescriptor=*/true); @@ -654,22 +654,22 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr, } else if (mlir::isa(Ty)) { return genBasicType(context, mlir::StringAttr::get(context, "real"), Ty.getIntOrFloatBitWidth(), llvm::dwarf::DW_ATE_float); - } else if (auto logTy = mlir::dyn_cast_or_null(Ty)) { + } else if (auto logTy = mlir::dyn_cast_if_present(Ty)) { return genBasicType(context, mlir::StringAttr::get(context, logTy.getMnemonic()), kindMapping.getLogicalBitsize(logTy.getFKind()), llvm::dwarf::DW_ATE_boolean); - } else if (auto cplxTy = mlir::dyn_cast_or_null(Ty)) { + } else if (auto cplxTy = mlir::dyn_cast_if_present(Ty)) { auto floatTy = mlir::cast(cplxTy.getElementType()); unsigned bitWidth = floatTy.getWidth(); return genBasicType(context, mlir::StringAttr::get(context, "complex"), bitWidth * 2, llvm::dwarf::DW_ATE_complex_float); - } else if (auto seqTy = mlir::dyn_cast_or_null(Ty)) { + } else if (auto seqTy = mlir::dyn_cast_if_present(Ty)) { return convertSequenceType(seqTy, fileAttr, scope, declOp); - } else if (auto charTy = mlir::dyn_cast_or_null(Ty)) { + } else if (auto charTy = mlir::dyn_cast_if_present(Ty)) { return convertCharacterType(charTy, fileAttr, scope, declOp, /*hasDescriptor=*/false); - } else if (auto recTy = mlir::dyn_cast_or_null(Ty)) { + } else if (auto recTy = mlir::dyn_cast_if_present(Ty)) { return convertRecordType(recTy, fileAttr, scope, declOp); } else if (auto tupleTy = mlir::dyn_cast_if_present(Ty)) { return convertTupleType(tupleTy, fileAttr, scope, declOp); @@ -678,22 +678,22 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr, return convertPointerLikeType(elTy, fileAttr, scope, declOp, /*genAllocated=*/false, /*genAssociated=*/false); - } else if (auto vecTy = mlir::dyn_cast_or_null(Ty)) { + } else if (auto vecTy = mlir::dyn_cast_if_present(Ty)) { return convertVectorType(vecTy, fileAttr, scope, declOp); } else if (mlir::isa(Ty)) { return genBasicType(context, mlir::StringAttr::get(context, "integer"), llvmTypeConverter.getIndexTypeBitwidth(), llvm::dwarf::DW_ATE_signed); - } else if (auto boxTy = mlir::dyn_cast_or_null(Ty)) { + } else if (auto boxTy = mlir::dyn_cast_if_present(Ty)) { auto elTy = boxTy.getEleTy(); - if (auto seqTy = mlir::dyn_cast_or_null(elTy)) + if (auto seqTy = mlir::dyn_cast_if_present(elTy)) return convertBoxedSequenceType(seqTy, fileAttr, scope, declOp, false, false); - if (auto heapTy = mlir::dyn_cast_or_null(elTy)) + if (auto heapTy = mlir::dyn_cast_if_present(elTy)) return convertPointerLikeType(heapTy.getElementType(), fileAttr, scope, declOp, /*genAllocated=*/true, /*genAssociated=*/false); - if (auto ptrTy = mlir::dyn_cast_or_null(elTy)) + if (auto ptrTy = mlir::dyn_cast_if_present(elTy)) return convertPointerLikeType(ptrTy.getElementType(), fileAttr, scope, declOp, /*genAllocated=*/false, /*genAssociated=*/true);