@@ -325,7 +325,7 @@ static bool canCacheThisType(mlir::LLVM::DICompositeTypeAttr comTy) {
325325std::pair<std::uint64_t , unsigned short >
326326DebugTypeGenerator::getFieldSizeAndAlign (mlir::Type fieldTy) {
327327 mlir::Type llvmTy;
328- if (auto boxTy = mlir::dyn_cast_or_null <fir::BaseBoxType>(fieldTy))
328+ if (auto boxTy = mlir::dyn_cast_if_present <fir::BaseBoxType>(fieldTy))
329329 llvmTy = llvmTypeConverter.convertBoxTypeAsStruct (boxTy, getBoxRank (boxTy));
330330 else
331331 llvmTy = llvmTypeConverter.convertType (fieldTy);
@@ -371,7 +371,7 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
371371 std::optional<llvm::ArrayRef<int64_t >> lowerBounds =
372372 fir::getComponentLowerBoundsIfNonDefault (Ty, fieldName, module ,
373373 symbolTable);
374- auto seqTy = mlir::dyn_cast_or_null <fir::SequenceType>(fieldTy);
374+ auto seqTy = mlir::dyn_cast_if_present <fir::SequenceType>(fieldTy);
375375
376376 // For members of the derived types, the information about the shift in
377377 // lower bounds is not part of the declOp but has to be extracted from the
@@ -622,10 +622,10 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertPointerLikeType(
622622 // Arrays and character need different treatment because DWARF have special
623623 // constructs for them to get the location from the descriptor. Rest of
624624 // types are handled like pointer to underlying type.
625- if (auto seqTy = mlir::dyn_cast_or_null <fir::SequenceType>(elTy))
625+ if (auto seqTy = mlir::dyn_cast_if_present <fir::SequenceType>(elTy))
626626 return convertBoxedSequenceType (seqTy, fileAttr, scope, declOp,
627627 genAllocated, genAssociated);
628- if (auto charTy = mlir::dyn_cast_or_null <fir::CharacterType>(elTy))
628+ if (auto charTy = mlir::dyn_cast_if_present <fir::CharacterType>(elTy))
629629 return convertCharacterType (charTy, fileAttr, scope, declOp,
630630 /* hasDescriptor=*/ true );
631631
@@ -654,22 +654,22 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
654654 } else if (mlir::isa<mlir::FloatType>(Ty)) {
655655 return genBasicType (context, mlir::StringAttr::get (context, " real" ),
656656 Ty.getIntOrFloatBitWidth (), llvm::dwarf::DW_ATE_float);
657- } else if (auto logTy = mlir::dyn_cast_or_null <fir::LogicalType>(Ty)) {
657+ } else if (auto logTy = mlir::dyn_cast_if_present <fir::LogicalType>(Ty)) {
658658 return genBasicType (context,
659659 mlir::StringAttr::get (context, logTy.getMnemonic ()),
660660 kindMapping.getLogicalBitsize (logTy.getFKind ()),
661661 llvm::dwarf::DW_ATE_boolean);
662- } else if (auto cplxTy = mlir::dyn_cast_or_null <mlir::ComplexType>(Ty)) {
662+ } else if (auto cplxTy = mlir::dyn_cast_if_present <mlir::ComplexType>(Ty)) {
663663 auto floatTy = mlir::cast<mlir::FloatType>(cplxTy.getElementType ());
664664 unsigned bitWidth = floatTy.getWidth ();
665665 return genBasicType (context, mlir::StringAttr::get (context, " complex" ),
666666 bitWidth * 2 , llvm::dwarf::DW_ATE_complex_float);
667- } else if (auto seqTy = mlir::dyn_cast_or_null <fir::SequenceType>(Ty)) {
667+ } else if (auto seqTy = mlir::dyn_cast_if_present <fir::SequenceType>(Ty)) {
668668 return convertSequenceType (seqTy, fileAttr, scope, declOp);
669- } else if (auto charTy = mlir::dyn_cast_or_null <fir::CharacterType>(Ty)) {
669+ } else if (auto charTy = mlir::dyn_cast_if_present <fir::CharacterType>(Ty)) {
670670 return convertCharacterType (charTy, fileAttr, scope, declOp,
671671 /* hasDescriptor=*/ false );
672- } else if (auto recTy = mlir::dyn_cast_or_null <fir::RecordType>(Ty)) {
672+ } else if (auto recTy = mlir::dyn_cast_if_present <fir::RecordType>(Ty)) {
673673 return convertRecordType (recTy, fileAttr, scope, declOp);
674674 } else if (auto tupleTy = mlir::dyn_cast_if_present<mlir::TupleType>(Ty)) {
675675 return convertTupleType (tupleTy, fileAttr, scope, declOp);
@@ -678,22 +678,22 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
678678 return convertPointerLikeType (elTy, fileAttr, scope, declOp,
679679 /* genAllocated=*/ false ,
680680 /* genAssociated=*/ false );
681- } else if (auto vecTy = mlir::dyn_cast_or_null <fir::VectorType>(Ty)) {
681+ } else if (auto vecTy = mlir::dyn_cast_if_present <fir::VectorType>(Ty)) {
682682 return convertVectorType (vecTy, fileAttr, scope, declOp);
683683 } else if (mlir::isa<mlir::IndexType>(Ty)) {
684684 return genBasicType (context, mlir::StringAttr::get (context, " integer" ),
685685 llvmTypeConverter.getIndexTypeBitwidth (),
686686 llvm::dwarf::DW_ATE_signed);
687- } else if (auto boxTy = mlir::dyn_cast_or_null <fir::BaseBoxType>(Ty)) {
687+ } else if (auto boxTy = mlir::dyn_cast_if_present <fir::BaseBoxType>(Ty)) {
688688 auto elTy = boxTy.getEleTy ();
689- if (auto seqTy = mlir::dyn_cast_or_null <fir::SequenceType>(elTy))
689+ if (auto seqTy = mlir::dyn_cast_if_present <fir::SequenceType>(elTy))
690690 return convertBoxedSequenceType (seqTy, fileAttr, scope, declOp, false ,
691691 false );
692- if (auto heapTy = mlir::dyn_cast_or_null <fir::HeapType>(elTy))
692+ if (auto heapTy = mlir::dyn_cast_if_present <fir::HeapType>(elTy))
693693 return convertPointerLikeType (heapTy.getElementType (), fileAttr, scope,
694694 declOp, /* genAllocated=*/ true ,
695695 /* genAssociated=*/ false );
696- if (auto ptrTy = mlir::dyn_cast_or_null <fir::PointerType>(elTy))
696+ if (auto ptrTy = mlir::dyn_cast_if_present <fir::PointerType>(elTy))
697697 return convertPointerLikeType (ptrTy.getElementType (), fileAttr, scope,
698698 declOp, /* genAllocated=*/ false ,
699699 /* genAssociated=*/ true );
0 commit comments