[llvm-branch-commits] [lldb] [lldb][Fortran] Added support for functions to DWARFASTParserFortran (PR #234312)

David Spickett via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Oct 23 06:56:11 PDT 2026


================
@@ -146,13 +177,61 @@ lldb::TypeSP DWARFASTParserFortran::ParseTypeFromDWARF(
                         compiler_type, Type::ResolveState::Full);
     break;
   }
+  case DW_TAG_subprogram:
+  case DW_TAG_subroutine_type: {
+    CompilerType return_type;
+    dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
+    attributes = die.GetAttributes();
+    size_t num_attr = attributes.Size();
+
+    for (size_t i = 0; i < num_attr; ++i) {
+      if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+        switch (attributes.AttributeAtIndex(i)) {
+        case DW_AT_name:
+          type_name_cstr = form_value.AsCString();
+          if (type_name_cstr &&
+              type_name_cstr[0]) { // Check for null AND empty string
+            type_name.SetString(llvm::StringRef(type_name_cstr));
+          } else {
+            type_name.SetCString("UNKNOWN_FORTRAN_FUNCTION");
+          }
+          break;
+
+        case DW_AT_type: {
+          DWARFDIE type_die = form_value.Reference();
+          if (!type_die)
+            break;
+
+          if (Type *resolved_type = die.GetDWARF()->ResolveType(type_die))
+            return_type = resolved_type->GetForwardCompilerType();
+
+          break;
----------------
DavidSpickett wrote:

You could use if delcarations to make this simpler, since every path leads to a break eventually.
```
if (DWARFDIE type_die = form_value.Reference())
  if (Type *resolved_type = die.GetDWARF()->ResolveType(type_die))
    return_type = resolved_type->GetForwardCompilerType();

break;
```
Then you have one break, and yes it's not early returning but this number of lines fits easily on screen so I think fewer breaks wins here.

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


More information about the llvm-branch-commits mailing list