| ... | ... | @@ -2313,7 +2313,29 @@ pub const DeclGen = struct { |
| 2313 | 2313 | return gop.value_ptr.*; |
| 2314 | 2314 | }, |
| 2315 | 2315 | .Struct => { |
| 2316 | const owner_decl = ty.getOwnerDecl(); |
| 2317 | |
| 2318 | const name = try ty.nameAlloc(gpa); // TODO this is a leak |
| 2319 | const fwd_decl = dib.createReplaceableCompositeType( |
| 2320 | DW.TAG.structure_type, |
| 2321 | name.ptr, |
| 2322 | dg.object.di_compile_unit.?.toScope(), |
| 2323 | null, // file |
| 2324 | 0, // line |
| 2325 | ); |
| 2326 | gop.value_ptr.* = fwd_decl; |
| 2327 | |
| 2328 | const TODO_implement_this = true; // TODO |
| 2329 | if (TODO_implement_this or !ty.hasRuntimeBits()) { |
| 2330 | const struct_di_ty = try dg.makeEmptyNamespaceDIType(owner_decl); |
| 2331 | dib.replaceTemporary(fwd_decl, struct_di_ty); |
| 2332 | // The recursive call to `lowerDebugType` via `makeEmptyNamespaceDIType` |
| 2333 | // means we can't use `gop` anymore. |
| 2334 | try dg.object.di_type_map.put(gpa, ty, struct_di_ty); |
| 2335 | return struct_di_ty; |
| 2336 | } |
| 2316 | 2337 | @panic("TODO debug info type for struct"); |
| 2338 | |
| 2317 | 2339 | //const gop = try dg.object.type_map.getOrPut(gpa, ty); |
| 2318 | 2340 | //if (gop.found_existing) return gop.value_ptr.*; |
| 2319 | 2341 | |
| ... | ... | @@ -2437,6 +2459,28 @@ pub const DeclGen = struct { |
| 2437 | 2459 | //return llvm_struct_ty; |
| 2438 | 2460 | }, |
| 2439 | 2461 | .Union => { |
| 2462 | const owner_decl = ty.getOwnerDecl(); |
| 2463 | |
| 2464 | const name = try ty.nameAlloc(gpa); // TODO this is a leak |
| 2465 | const fwd_decl = dib.createReplaceableCompositeType( |
| 2466 | DW.TAG.structure_type, |
| 2467 | name.ptr, |
| 2468 | dg.object.di_compile_unit.?.toScope(), |
| 2469 | null, // file |
| 2470 | 0, // line |
| 2471 | ); |
| 2472 | gop.value_ptr.* = fwd_decl; |
| 2473 | |
| 2474 | const TODO_implement_this = true; // TODO |
| 2475 | if (TODO_implement_this or !ty.hasRuntimeBits()) { |
| 2476 | const union_di_ty = try dg.makeEmptyNamespaceDIType(owner_decl); |
| 2477 | dib.replaceTemporary(fwd_decl, union_di_ty); |
| 2478 | // The recursive call to `lowerDebugType` via `makeEmptyNamespaceDIType` |
| 2479 | // means we can't use `gop` anymore. |
| 2480 | try dg.object.di_type_map.put(gpa, ty, union_di_ty); |
| 2481 | return union_di_ty; |
| 2482 | } |
| 2483 | |
| 2440 | 2484 | @panic("TODO debug info type for union"); |
| 2441 | 2485 | //const gop = try dg.object.type_map.getOrPut(gpa, ty); |
| 2442 | 2486 | //if (gop.found_existing) return gop.value_ptr.*; |
| ... | ... | @@ -2561,6 +2605,10 @@ pub const DeclGen = struct { |
| 2561 | 2605 | } |
| 2562 | 2606 | |
| 2563 | 2607 | fn namespaceToDebugScope(dg: *DeclGen, namespace: *const Module.Namespace) !*llvm.DIScope { |
| 2608 | if (namespace.parent == null) { |
| 2609 | const di_file = try dg.object.getDIFile(dg.gpa, namespace.file_scope); |
| 2610 | return di_file.toScope(); |
| 2611 | } |
| 2564 | 2612 | const di_type = try dg.lowerDebugType(namespace.ty); |
| 2565 | 2613 | return di_type.toScope(); |
| 2566 | 2614 | } |
| ... | ... | @@ -3862,7 +3910,7 @@ pub const FuncGen = struct { |
| 3862 | 3910 | const di_scope = self.di_scope orelse return null; |
| 3863 | 3911 | const dbg_stmt = self.air.instructions.items(.data)[inst].dbg_stmt; |
| 3864 | 3912 | self.builder.setCurrentDebugLocation( |
| 3865 | | @intCast(c_int, dbg_stmt.line + 1), |
| 3913 | @intCast(c_int, self.dg.decl.src_line + dbg_stmt.line + 1), |
| 3866 | 3914 | @intCast(c_int, dbg_stmt.column + 1), |
| 3867 | 3915 | di_scope, |
| 3868 | 3916 | ); |