[flang-commits] [flang] [flang][debug] Support ClassType. (PR #114809)

via flang-commits flang-commits at lists.llvm.org
Wed Nov 13 01:58:35 PST 2024


================
@@ -628,8 +633,13 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
     return genBasicType(context, mlir::StringAttr::get(context, "integer"),
                         llvmTypeConverter.getIndexTypeBitwidth(),
                         llvm::dwarf::DW_ATE_signed);
-  } else if (auto boxTy = mlir::dyn_cast_or_null<fir::BoxType>(Ty)) {
-    auto elTy = boxTy.getElementType();
+  } else if (auto boxTy = mlir::dyn_cast_or_null<fir::BaseBoxType>(Ty)) {
+    if (mlir::isa<fir::ClassType>(Ty))
+      return convertPointerLikeType(boxTy.unwrapInnerType(), fileAttr, scope,
+                                    declOp, /*genAllocated=*/false,
+                                    /*genAssociated=*/true);
----------------
jeanPerier wrote:

I do not get why `ClassType` is bypassing the handling below made for BoxType and why `genAssociated` would be always true for them even when they are not POINTERs.

With the exception of the polymorphic aspect (the fact that the dynamic type may be an extension of the static type), which seems not straightforward to represent in DWARF, a fir.class is just like a fir.box. So the representation of the static type of a fir.box and fir.class should be the the same I think.

My comment about `CLASS(*)` may have mislead you here. I think it is OK to decide and agree how to represent those in a distinct patch, especially because they are also `TYPE(*)`, so `fir.box<none>` is also a thing.

https://github.com/llvm/llvm-project/pull/114809


More information about the flang-commits mailing list