@@ -629,7 +629,12 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertPointerLikeType(
629
629
return convertCharacterType (charTy, fileAttr, scope, declOp,
630
630
/* hasDescriptor=*/ true );
631
631
632
- mlir::LLVM::DITypeAttr elTyAttr = convertType (elTy, fileAttr, scope, declOp);
632
+ // If elTy is null or none then generate a void*
633
+ mlir::LLVM::DITypeAttr elTyAttr;
634
+ if (!elTy || mlir::isa<mlir::NoneType>(elTy))
635
+ elTyAttr = mlir::LLVM::DINullTypeAttr::get (context);
636
+ else
637
+ elTyAttr = convertType (elTy, fileAttr, scope, declOp);
633
638
634
639
return mlir::LLVM::DIDerivedTypeAttr::get (
635
640
context, llvm::dwarf::DW_TAG_pointer_type,
@@ -668,20 +673,6 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
668
673
return convertRecordType (recTy, fileAttr, scope, declOp);
669
674
} else if (auto tupleTy = mlir::dyn_cast_if_present<mlir::TupleType>(Ty)) {
670
675
return convertTupleType (tupleTy, fileAttr, scope, declOp);
671
- } else if (auto classTy = mlir::dyn_cast_if_present<fir::ClassType>(Ty)) {
672
- // ClassType when passed to the function have double indirection so it
673
- // is represented as pointer to type (and not type as a RecordType will be
674
- // for example). If ClassType wraps a pointer or allocatable then we get
675
- // the real underlying type to avoid translating the Ty to
676
- // Ptr -> Ptr -> type.
677
- mlir::Type elTy = classTy.getEleTy ();
678
- if (auto ptrTy = mlir::dyn_cast_if_present<fir::PointerType>(elTy))
679
- elTy = ptrTy.getElementType ();
680
- else if (auto heapTy = mlir::dyn_cast_if_present<fir::HeapType>(elTy))
681
- elTy = heapTy.getElementType ();
682
- return convertPointerLikeType (elTy, fileAttr, scope, declOp,
683
- /* genAllocated=*/ false ,
684
- /* genAssociated=*/ false );
685
676
} else if (auto refTy = mlir::dyn_cast_if_present<fir::ReferenceType>(Ty)) {
686
677
auto elTy = refTy.getEleTy ();
687
678
return convertPointerLikeType (elTy, fileAttr, scope, declOp,
@@ -693,8 +684,13 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
693
684
return genBasicType (context, mlir::StringAttr::get (context, " integer" ),
694
685
llvmTypeConverter.getIndexTypeBitwidth (),
695
686
llvm::dwarf::DW_ATE_signed);
696
- } else if (auto boxTy = mlir::dyn_cast_or_null<fir::BoxType>(Ty)) {
697
- auto elTy = boxTy.getElementType ();
687
+ } else if (auto boxTy = mlir::dyn_cast_or_null<fir::BaseBoxType>(Ty)) {
688
+ if (mlir::isa<fir::ClassType>(Ty))
689
+ return convertPointerLikeType (boxTy.unwrapInnerType (), fileAttr, scope,
690
+ declOp, /* genAllocated=*/ false ,
691
+ /* genAssociated=*/ true );
692
+
693
+ auto elTy = boxTy.getEleTy ();
698
694
if (auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(elTy))
699
695
return convertBoxedSequenceType (seqTy, fileAttr, scope, declOp, false ,
700
696
false );
0 commit comments