@@ -325,7 +325,7 @@ static bool canCacheThisType(mlir::LLVM::DICompositeTypeAttr comTy) {
325
325
std::pair<std::uint64_t , unsigned short >
326
326
DebugTypeGenerator::getFieldSizeAndAlign (mlir::Type fieldTy) {
327
327
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))
329
329
llvmTy = llvmTypeConverter.convertBoxTypeAsStruct (boxTy, getBoxRank (boxTy));
330
330
else
331
331
llvmTy = llvmTypeConverter.convertType (fieldTy);
@@ -371,7 +371,7 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
371
371
std::optional<llvm::ArrayRef<int64_t >> lowerBounds =
372
372
fir::getComponentLowerBoundsIfNonDefault (Ty, fieldName, module ,
373
373
symbolTable);
374
- auto seqTy = mlir::dyn_cast_or_null <fir::SequenceType>(fieldTy);
374
+ auto seqTy = mlir::dyn_cast_if_present <fir::SequenceType>(fieldTy);
375
375
376
376
// For members of the derived types, the information about the shift in
377
377
// lower bounds is not part of the declOp but has to be extracted from the
@@ -622,10 +622,10 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertPointerLikeType(
622
622
// Arrays and character need different treatment because DWARF have special
623
623
// constructs for them to get the location from the descriptor. Rest of
624
624
// 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))
626
626
return convertBoxedSequenceType (seqTy, fileAttr, scope, declOp,
627
627
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))
629
629
return convertCharacterType (charTy, fileAttr, scope, declOp,
630
630
/* hasDescriptor=*/ true );
631
631
@@ -654,22 +654,22 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
654
654
} else if (mlir::isa<mlir::FloatType>(Ty)) {
655
655
return genBasicType (context, mlir::StringAttr::get (context, " real" ),
656
656
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)) {
658
658
return genBasicType (context,
659
659
mlir::StringAttr::get (context, logTy.getMnemonic ()),
660
660
kindMapping.getLogicalBitsize (logTy.getFKind ()),
661
661
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)) {
663
663
auto floatTy = mlir::cast<mlir::FloatType>(cplxTy.getElementType ());
664
664
unsigned bitWidth = floatTy.getWidth ();
665
665
return genBasicType (context, mlir::StringAttr::get (context, " complex" ),
666
666
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)) {
668
668
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)) {
670
670
return convertCharacterType (charTy, fileAttr, scope, declOp,
671
671
/* 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)) {
673
673
return convertRecordType (recTy, fileAttr, scope, declOp);
674
674
} else if (auto tupleTy = mlir::dyn_cast_if_present<mlir::TupleType>(Ty)) {
675
675
return convertTupleType (tupleTy, fileAttr, scope, declOp);
@@ -678,22 +678,22 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
678
678
return convertPointerLikeType (elTy, fileAttr, scope, declOp,
679
679
/* genAllocated=*/ false ,
680
680
/* 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)) {
682
682
return convertVectorType (vecTy, fileAttr, scope, declOp);
683
683
} else if (mlir::isa<mlir::IndexType>(Ty)) {
684
684
return genBasicType (context, mlir::StringAttr::get (context, " integer" ),
685
685
llvmTypeConverter.getIndexTypeBitwidth (),
686
686
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)) {
688
688
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))
690
690
return convertBoxedSequenceType (seqTy, fileAttr, scope, declOp, false ,
691
691
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))
693
693
return convertPointerLikeType (heapTy.getElementType (), fileAttr, scope,
694
694
declOp, /* genAllocated=*/ true ,
695
695
/* 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))
697
697
return convertPointerLikeType (ptrTy.getElementType (), fileAttr, scope,
698
698
declOp, /* genAllocated=*/ false ,
699
699
/* genAssociated=*/ true );
0 commit comments