| ... | ... | @@ -2259,25 +2259,20 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2259 | 2259 | switch (ip.indexToKey(nav_val.toIntern())) { |
| 2260 | 2260 | else => { |
| 2261 | 2261 | assert(file.zir_loaded); |
| 2262 | | const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst)); |
| 2263 | | assert(decl_inst.tag == .declaration); |
| 2264 | | const tree = try file.getTree(dwarf.gpa); |
| 2265 | | const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]); |
| 2266 | | assert(loc.line == zcu.navSrcLine(nav_index)); |
| 2262 | const decl = file.zir.getDeclaration(inst_info.inst)[0]; |
| 2267 | 2263 | |
| 2268 | 2264 | const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: { |
| 2269 | | const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index).data; |
| 2270 | 2265 | const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace); |
| 2271 | 2266 | break :parent .{ |
| 2272 | 2267 | parent_namespace_ptr.owner_type, |
| 2273 | | switch (decl_extra.name) { |
| 2268 | switch (decl.name) { |
| 2274 | 2269 | .@"comptime", |
| 2275 | 2270 | .@"usingnamespace", |
| 2276 | 2271 | .unnamed_test, |
| 2277 | 2272 | => DW.ACCESS.private, |
| 2278 | | _ => if (decl_extra.name.isNamedTest(file.zir)) |
| 2273 | _ => if (decl.name.isNamedTest(file.zir)) |
| 2279 | 2274 | DW.ACCESS.private |
| 2280 | | else if (decl_extra.flags.is_pub) |
| 2275 | else if (decl.flags.is_pub) |
| 2281 | 2276 | DW.ACCESS.public |
| 2282 | 2277 | else |
| 2283 | 2278 | DW.ACCESS.private, |
| ... | ... | @@ -2289,8 +2284,8 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2289 | 2284 | try wip_nav.abbrevCode(.decl_var); |
| 2290 | 2285 | try wip_nav.refType(.fromInterned(parent_type)); |
| 2291 | 2286 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2292 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2293 | | try uleb128(diw, loc.column + 1); |
| 2287 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2288 | try uleb128(diw, decl.src_column + 1); |
| 2294 | 2289 | try diw.writeByte(accessibility); |
| 2295 | 2290 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2296 | 2291 | try wip_nav.strp(nav.fqn.toSlice(ip)); |
| ... | ... | @@ -2306,25 +2301,20 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2306 | 2301 | }, |
| 2307 | 2302 | .variable => |variable| { |
| 2308 | 2303 | assert(file.zir_loaded); |
| 2309 | | const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst)); |
| 2310 | | assert(decl_inst.tag == .declaration); |
| 2311 | | const tree = try file.getTree(dwarf.gpa); |
| 2312 | | const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]); |
| 2313 | | assert(loc.line == zcu.navSrcLine(nav_index)); |
| 2304 | const decl = file.zir.getDeclaration(inst_info.inst)[0]; |
| 2314 | 2305 | |
| 2315 | 2306 | const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: { |
| 2316 | | const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index).data; |
| 2317 | 2307 | const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace); |
| 2318 | 2308 | break :parent .{ |
| 2319 | 2309 | parent_namespace_ptr.owner_type, |
| 2320 | | switch (decl_extra.name) { |
| 2310 | switch (decl.name) { |
| 2321 | 2311 | .@"comptime", |
| 2322 | 2312 | .@"usingnamespace", |
| 2323 | 2313 | .unnamed_test, |
| 2324 | 2314 | => DW.ACCESS.private, |
| 2325 | | _ => if (decl_extra.name.isNamedTest(file.zir)) |
| 2315 | _ => if (decl.name.isNamedTest(file.zir)) |
| 2326 | 2316 | DW.ACCESS.private |
| 2327 | | else if (decl_extra.flags.is_pub) |
| 2317 | else if (decl.flags.is_pub) |
| 2328 | 2318 | DW.ACCESS.public |
| 2329 | 2319 | else |
| 2330 | 2320 | DW.ACCESS.private, |
| ... | ... | @@ -2336,8 +2326,8 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2336 | 2326 | try wip_nav.abbrevCode(.decl_var); |
| 2337 | 2327 | try wip_nav.refType(.fromInterned(parent_type)); |
| 2338 | 2328 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2339 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2340 | | try uleb128(diw, loc.column + 1); |
| 2329 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2330 | try uleb128(diw, decl.src_column + 1); |
| 2341 | 2331 | try diw.writeByte(accessibility); |
| 2342 | 2332 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2343 | 2333 | try wip_nav.strp(nav.fqn.toSlice(ip)); |
| ... | ... | @@ -2351,25 +2341,20 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2351 | 2341 | }, |
| 2352 | 2342 | .func => |func| { |
| 2353 | 2343 | assert(file.zir_loaded); |
| 2354 | | const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst)); |
| 2355 | | assert(decl_inst.tag == .declaration); |
| 2356 | | const tree = try file.getTree(dwarf.gpa); |
| 2357 | | const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]); |
| 2358 | | assert(loc.line == zcu.navSrcLine(nav_index)); |
| 2344 | const decl = file.zir.getDeclaration(inst_info.inst)[0]; |
| 2359 | 2345 | |
| 2360 | 2346 | const parent_type, const accessibility: u8 = if (nav.analysis_owner.unwrap()) |cau| parent: { |
| 2361 | | const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index).data; |
| 2362 | 2347 | const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace); |
| 2363 | 2348 | break :parent .{ |
| 2364 | 2349 | parent_namespace_ptr.owner_type, |
| 2365 | | switch (decl_extra.name) { |
| 2350 | switch (decl.name) { |
| 2366 | 2351 | .@"comptime", |
| 2367 | 2352 | .@"usingnamespace", |
| 2368 | 2353 | .unnamed_test, |
| 2369 | 2354 | => DW.ACCESS.private, |
| 2370 | | _ => if (decl_extra.name.isNamedTest(file.zir)) |
| 2355 | _ => if (decl.name.isNamedTest(file.zir)) |
| 2371 | 2356 | DW.ACCESS.private |
| 2372 | | else if (decl_extra.flags.is_pub) |
| 2357 | else if (decl.flags.is_pub) |
| 2373 | 2358 | DW.ACCESS.public |
| 2374 | 2359 | else |
| 2375 | 2360 | DW.ACCESS.private, |
| ... | ... | @@ -2426,8 +2411,8 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2426 | 2411 | try wip_nav.abbrevCode(.decl_func); |
| 2427 | 2412 | try wip_nav.refType(.fromInterned(parent_type)); |
| 2428 | 2413 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2429 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2430 | | try uleb128(diw, loc.column + 1); |
| 2414 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2415 | try uleb128(diw, decl.src_column + 1); |
| 2431 | 2416 | try diw.writeByte(accessibility); |
| 2432 | 2417 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2433 | 2418 | try wip_nav.strp(nav.fqn.toSlice(ip)); |
| ... | ... | @@ -2476,7 +2461,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2476 | 2461 | try dlw.writeByte(DW.LNS.set_column); |
| 2477 | 2462 | try uleb128(dlw, func.lbrace_column + 1); |
| 2478 | 2463 | |
| 2479 | | try wip_nav.advancePCAndLine(@intCast(loc.line + func.lbrace_line), 0); |
| 2464 | try wip_nav.advancePCAndLine(@intCast(decl.src_line + func.lbrace_line), 0); |
| 2480 | 2465 | } |
| 2481 | 2466 | }, |
| 2482 | 2467 | } |
| ... | ... | @@ -2600,14 +2585,12 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2600 | 2585 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| 2601 | 2586 | const file = zcu.fileByIndex(inst_info.file); |
| 2602 | 2587 | assert(file.zir_loaded); |
| 2603 | | const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst)); |
| 2604 | | assert(decl_inst.tag == .declaration); |
| 2605 | | const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index); |
| 2588 | const decl = file.zir.getDeclaration(inst_info.inst)[0]; |
| 2606 | 2589 | |
| 2607 | | const is_test = switch (decl_extra.data.name) { |
| 2590 | const is_test = switch (decl.name) { |
| 2608 | 2591 | .unnamed_test => true, |
| 2609 | 2592 | .@"comptime", .@"usingnamespace" => false, |
| 2610 | | _ => decl_extra.data.name.isNamedTest(file.zir), |
| 2593 | _ => decl.name.isNamedTest(file.zir), |
| 2611 | 2594 | }; |
| 2612 | 2595 | if (is_test) { |
| 2613 | 2596 | // This isn't actually a comptime Nav! It's a test, so it'll definitely never be referenced at comptime. |
| ... | ... | @@ -2618,14 +2601,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2618 | 2601 | const parent_namespace_ptr = ip.namespacePtr(ip.getCau(cau).namespace); |
| 2619 | 2602 | break :parent .{ |
| 2620 | 2603 | parent_namespace_ptr.owner_type, |
| 2621 | | if (decl_extra.data.flags.is_pub) DW.ACCESS.public else DW.ACCESS.private, |
| 2604 | if (decl.flags.is_pub) DW.ACCESS.public else DW.ACCESS.private, |
| 2622 | 2605 | }; |
| 2623 | 2606 | } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private }; |
| 2624 | 2607 | |
| 2625 | | const tree = try file.getTree(dwarf.gpa); |
| 2626 | | const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]); |
| 2627 | | assert(loc.line == zcu.navSrcLine(nav_index)); |
| 2628 | | |
| 2629 | 2608 | var wip_nav: WipNav = .{ |
| 2630 | 2609 | .dwarf = dwarf, |
| 2631 | 2610 | .pt = pt, |
| ... | ... | @@ -2688,8 +2667,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2688 | 2667 | try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .decl_namespace_struct else .decl_struct); |
| 2689 | 2668 | try wip_nav.refType(.fromInterned(parent_type)); |
| 2690 | 2669 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2691 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2692 | | try uleb128(diw, loc.column + 1); |
| 2670 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2671 | try uleb128(diw, decl.src_column + 1); |
| 2693 | 2672 | try diw.writeByte(accessibility); |
| 2694 | 2673 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2695 | 2674 | if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else { |
| ... | ... | @@ -2748,8 +2727,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2748 | 2727 | try wip_nav.abbrevCode(.decl_packed_struct); |
| 2749 | 2728 | try wip_nav.refType(.fromInterned(parent_type)); |
| 2750 | 2729 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2751 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2752 | | try uleb128(diw, loc.column + 1); |
| 2730 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2731 | try uleb128(diw, decl.src_column + 1); |
| 2753 | 2732 | try diw.writeByte(accessibility); |
| 2754 | 2733 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2755 | 2734 | try wip_nav.refType(.fromInterned(loaded_struct.backingIntTypeUnordered(ip))); |
| ... | ... | @@ -2790,8 +2769,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2790 | 2769 | try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .decl_enum else .decl_empty_enum); |
| 2791 | 2770 | try wip_nav.refType(.fromInterned(parent_type)); |
| 2792 | 2771 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2793 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2794 | | try uleb128(diw, loc.column + 1); |
| 2772 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2773 | try uleb128(diw, decl.src_column + 1); |
| 2795 | 2774 | try diw.writeByte(accessibility); |
| 2796 | 2775 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2797 | 2776 | try wip_nav.refType(.fromInterned(loaded_enum.tag_ty)); |
| ... | ... | @@ -2828,8 +2807,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2828 | 2807 | try wip_nav.abbrevCode(.decl_union); |
| 2829 | 2808 | try wip_nav.refType(.fromInterned(parent_type)); |
| 2830 | 2809 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2831 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2832 | | try uleb128(diw, loc.column + 1); |
| 2810 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2811 | try uleb128(diw, decl.src_column + 1); |
| 2833 | 2812 | try diw.writeByte(accessibility); |
| 2834 | 2813 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2835 | 2814 | const union_layout = Type.getUnionLayout(loaded_union, zcu); |
| ... | ... | @@ -2902,8 +2881,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2902 | 2881 | try wip_nav.abbrevCode(.decl_namespace_struct); |
| 2903 | 2882 | try wip_nav.refType(.fromInterned(parent_type)); |
| 2904 | 2883 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2905 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2906 | | try uleb128(diw, loc.column + 1); |
| 2884 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2885 | try uleb128(diw, decl.src_column + 1); |
| 2907 | 2886 | try diw.writeByte(accessibility); |
| 2908 | 2887 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2909 | 2888 | try diw.writeByte(@intFromBool(false)); |
| ... | ... | @@ -2958,8 +2937,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2958 | 2937 | .decl_empty_func_generic); |
| 2959 | 2938 | try wip_nav.refType(.fromInterned(parent_type)); |
| 2960 | 2939 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2961 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2962 | | try uleb128(diw, loc.column + 1); |
| 2940 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2941 | try uleb128(diw, decl.src_column + 1); |
| 2963 | 2942 | try diw.writeByte(accessibility); |
| 2964 | 2943 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2965 | 2944 | try wip_nav.refType(.fromInterned(func_type.return_type)); |
| ... | ... | @@ -2990,8 +2969,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2990 | 2969 | try wip_nav.abbrevCode(.decl_alias); |
| 2991 | 2970 | try wip_nav.refType(.fromInterned(parent_type)); |
| 2992 | 2971 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2993 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 2994 | | try uleb128(diw, loc.column + 1); |
| 2972 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2973 | try uleb128(diw, decl.src_column + 1); |
| 2995 | 2974 | try diw.writeByte(accessibility); |
| 2996 | 2975 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2997 | 2976 | try wip_nav.refType(nav_val.toType()); |
| ... | ... | @@ -3001,8 +2980,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 3001 | 2980 | try wip_nav.abbrevCode(.decl_var); |
| 3002 | 2981 | try wip_nav.refType(.fromInterned(parent_type)); |
| 3003 | 2982 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 3004 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 3005 | | try uleb128(diw, loc.column + 1); |
| 2983 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2984 | try uleb128(diw, decl.src_column + 1); |
| 3006 | 2985 | try diw.writeByte(accessibility); |
| 3007 | 2986 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 3008 | 2987 | try wip_nav.strp(nav.fqn.toSlice(ip)); |
| ... | ... | @@ -3028,8 +3007,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 3028 | 3007 | .decl_const); |
| 3029 | 3008 | try wip_nav.refType(.fromInterned(parent_type)); |
| 3030 | 3009 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 3031 | | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); |
| 3032 | | try uleb128(diw, loc.column + 1); |
| 3010 | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 3011 | try uleb128(diw, decl.src_column + 1); |
| 3033 | 3012 | try diw.writeByte(accessibility); |
| 3034 | 3013 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 3035 | 3014 | try wip_nav.strp(nav.fqn.toSlice(ip)); |