[flang-commits] [flang] [flang][debug] Improve handling of dummy character arguments. (PR #108283)

Abid Qadeer via flang-commits flang-commits at lists.llvm.org
Wed Sep 18 05:32:45 PDT 2024


================
@@ -289,7 +290,29 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertCharacterType(
     sizeInBits =
         charTy.getLen() * kindMapping.getCharacterBitsize(charTy.getFKind());
   } else {
-    return genPlaceholderType(context);
+    // In assumed length string, the len of the character is not part of the
+    // type but can be found at the runtime. Here we create an artificial
+    // variable that will contain that length. This variable is used as
+    // 'stringLength' in DIStringTypeAttr.
+    if (declOp && !declOp.getTypeparams().empty()) {
+      mlir::Operation *op = declOp.getTypeparams()[0].getDefiningOp();
+      if (auto unbox = mlir::dyn_cast_or_null<fir::UnboxCharOp>(op)) {
----------------
abidh wrote:

Thanks. This is another very useful suggestion. It will cover another instance where we were not showing the correct value of the variable. I am going to bring this in another PR as it will require more tests to be added.

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


More information about the flang-commits mailing list