| ... | @@ -448,6 +448,21 @@ pub const Block = struct { | ... | @@ -448,6 +448,21 @@ pub const Block = struct { |
| 448 | func: InternPool.Index, | 448 | func: InternPool.Index, |
| 449 | comptime_result: Air.Inst.Ref, | 449 | comptime_result: Air.Inst.Ref, |
| 450 | merges: Merges, | 450 | merges: Merges, |
| | 451 | /// Populated lazily by `refFrame`. |
| | 452 | ref_frame: Zcu.InlineReferenceFrame.Index.Optional = .none, |
| | 453 | |
| | 454 | fn refFrame(inlining: *Inlining, zcu: *Zcu) Allocator.Error!Zcu.InlineReferenceFrame.Index { |
| | 455 | if (inlining.ref_frame == .none) { |
| | 456 | inlining.ref_frame = (try zcu.addInlineReferenceFrame(.{ |
| | 457 | .callee = inlining.func, |
| | 458 | .call_src = inlining.call_src, |
| | 459 | .parent = if (inlining.call_block.inlining) |parent_inlining| p: { |
| | 460 | break :p (try parent_inlining.refFrame(zcu)).toOptional(); |
| | 461 | } else .none, |
| | 462 | })).toOptional(); |
| | 463 | } |
| | 464 | return inlining.ref_frame.unwrap().?; |
| | 465 | } |
| 451 | }; | 466 | }; |
| 452 | | 467 | |
| 453 | pub const Merges = struct { | 468 | pub const Merges = struct { |
| ... | @@ -4287,7 +4302,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -4287,7 +4302,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 4287 | if (zcu.intern_pool.isFuncBody(val)) { | 4302 | if (zcu.intern_pool.isFuncBody(val)) { |
| 4288 | const ty = Type.fromInterned(zcu.intern_pool.typeOf(val)); | 4303 | const ty = Type.fromInterned(zcu.intern_pool.typeOf(val)); |
| 4289 | if (try ty.fnHasRuntimeBitsSema(pt)) { | 4304 | if (try ty.fnHasRuntimeBitsSema(pt)) { |
| 4290 | try sema.addReferenceEntry(src, AnalUnit.wrap(.{ .func = val })); | 4305 | try sema.addReferenceEntry(block, src, AnalUnit.wrap(.{ .func = val })); |
| 4291 | try zcu.ensureFuncBodyAnalysisQueued(val); | 4306 | try zcu.ensureFuncBodyAnalysisQueued(val); |
| 4292 | } | 4307 | } |
| 4293 | } | 4308 | } |
| ... | @@ -6615,7 +6630,7 @@ pub fn analyzeExport( | ... | @@ -6615,7 +6630,7 @@ pub fn analyzeExport( |
| 6615 | if (options.linkage == .internal) | 6630 | if (options.linkage == .internal) |
| 6616 | return; | 6631 | return; |
| 6617 | | 6632 | |
| 6618 | try sema.ensureNavResolved(src, orig_nav_index, .fully); | 6633 | try sema.ensureNavResolved(block, src, orig_nav_index, .fully); |
| 6619 | | 6634 | |
| 6620 | const exported_nav_index = switch (ip.indexToKey(ip.getNav(orig_nav_index).status.fully_resolved.val)) { | 6635 | const exported_nav_index = switch (ip.indexToKey(ip.getNav(orig_nav_index).status.fully_resolved.val)) { |
| 6621 | .variable => |v| v.owner_nav, | 6636 | .variable => |v| v.owner_nav, |
| ... | @@ -6644,7 +6659,7 @@ pub fn analyzeExport( | ... | @@ -6644,7 +6659,7 @@ pub fn analyzeExport( |
| 6644 | return sema.fail(block, src, "export target cannot be extern", .{}); | 6659 | return sema.fail(block, src, "export target cannot be extern", .{}); |
| 6645 | } | 6660 | } |
| 6646 | | 6661 | |
| 6647 | try sema.maybeQueueFuncBodyAnalysis(src, exported_nav_index); | 6662 | try sema.maybeQueueFuncBodyAnalysis(block, src, exported_nav_index); |
| 6648 | | 6663 | |
| 6649 | try sema.exports.append(gpa, .{ | 6664 | try sema.exports.append(gpa, .{ |
| 6650 | .opts = options, | 6665 | .opts = options, |
| ... | @@ -6892,7 +6907,7 @@ fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -6892,7 +6907,7 @@ fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 6892 | .no_embedded_nulls, | 6907 | .no_embedded_nulls, |
| 6893 | ); | 6908 | ); |
| 6894 | const nav_index = try sema.lookupIdentifier(block, src, decl_name); | 6909 | const nav_index = try sema.lookupIdentifier(block, src, decl_name); |
| 6895 | return sema.analyzeNavRef(src, nav_index); | 6910 | return sema.analyzeNavRef(block, src, nav_index); |
| 6896 | } | 6911 | } |
| 6897 | | 6912 | |
| 6898 | fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 6913 | fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -6988,7 +7003,7 @@ fn lookupInNamespace( | ... | @@ -6988,7 +7003,7 @@ fn lookupInNamespace( |
| 6988 | } | 7003 | } |
| 6989 | | 7004 | |
| 6990 | for (usingnamespaces.items) |sub_ns_nav| { | 7005 | for (usingnamespaces.items) |sub_ns_nav| { |
| 6991 | try sema.ensureNavResolved(src, sub_ns_nav, .fully); | 7006 | try sema.ensureNavResolved(block, src, sub_ns_nav, .fully); |
| 6992 | const sub_ns_ty = Type.fromInterned(ip.getNav(sub_ns_nav).status.fully_resolved.val); | 7007 | const sub_ns_ty = Type.fromInterned(ip.getNav(sub_ns_nav).status.fully_resolved.val); |
| 6993 | const sub_ns = zcu.namespacePtr(sub_ns_ty.getNamespaceIndex(zcu)); | 7008 | const sub_ns = zcu.namespacePtr(sub_ns_ty.getNamespaceIndex(zcu)); |
| 6994 | try checked_namespaces.put(gpa, sub_ns, {}); | 7009 | try checked_namespaces.put(gpa, sub_ns, {}); |
| ... | @@ -7720,8 +7735,8 @@ fn analyzeCall( | ... | @@ -7720,8 +7735,8 @@ fn analyzeCall( |
| 7720 | var generic_inlining: Block.Inlining = if (func_ty_info.is_generic) .{ | 7735 | var generic_inlining: Block.Inlining = if (func_ty_info.is_generic) .{ |
| 7721 | .call_block = block, | 7736 | .call_block = block, |
| 7722 | .call_src = call_src, | 7737 | .call_src = call_src, |
| | 7738 | .func = func_val.?.toIntern(), |
| 7723 | .has_comptime_args = false, // unused by error reporting | 7739 | .has_comptime_args = false, // unused by error reporting |
| 7724 | .func = .none, // unused by error reporting | | |
| 7725 | .comptime_result = .none, // unused by error reporting | 7740 | .comptime_result = .none, // unused by error reporting |
| 7726 | .merges = undefined, // unused because we'll never `return` | 7741 | .merges = undefined, // unused because we'll never `return` |
| 7727 | } else undefined; | 7742 | } else undefined; |
| ... | @@ -7999,7 +8014,7 @@ fn analyzeCall( | ... | @@ -7999,7 +8014,7 @@ fn analyzeCall( |
| 7999 | ref_func: { | 8014 | ref_func: { |
| 8000 | const runtime_func_val = try sema.resolveValue(runtime_func) orelse break :ref_func; | 8015 | const runtime_func_val = try sema.resolveValue(runtime_func) orelse break :ref_func; |
| 8001 | if (!ip.isFuncBody(runtime_func_val.toIntern())) break :ref_func; | 8016 | if (!ip.isFuncBody(runtime_func_val.toIntern())) break :ref_func; |
| 8002 | try sema.addReferenceEntry(call_src, .wrap(.{ .func = runtime_func_val.toIntern() })); | 8017 | try sema.addReferenceEntry(block, call_src, .wrap(.{ .func = runtime_func_val.toIntern() })); |
| 8003 | try zcu.ensureFuncBodyAnalysisQueued(runtime_func_val.toIntern()); | 8018 | try zcu.ensureFuncBodyAnalysisQueued(runtime_func_val.toIntern()); |
| 8004 | } | 8019 | } |
| 8005 | | 8020 | |
| ... | @@ -17254,7 +17269,7 @@ fn zirClosureGet(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat | ... | @@ -17254,7 +17269,7 @@ fn zirClosureGet(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat |
| 17254 | .@"comptime" => |index| return Air.internedToRef(index), | 17269 | .@"comptime" => |index| return Air.internedToRef(index), |
| 17255 | .runtime => |index| index, | 17270 | .runtime => |index| index, |
| 17256 | .nav_val => |nav| return sema.analyzeNavVal(block, src, nav), | 17271 | .nav_val => |nav| return sema.analyzeNavVal(block, src, nav), |
| 17257 | .nav_ref => |nav| return sema.analyzeNavRef(src, nav), | 17272 | .nav_ref => |nav| return sema.analyzeNavRef(block, src, nav), |
| 17258 | }; | 17273 | }; |
| 17259 | | 17274 | |
| 17260 | // The comptime case is handled already above. Runtime case below. | 17275 | // The comptime case is handled already above. Runtime case below. |
| ... | @@ -18407,7 +18422,7 @@ fn typeInfoNamespaceDecls( | ... | @@ -18407,7 +18422,7 @@ fn typeInfoNamespaceDecls( |
| 18407 | if (zcu.analysis_in_progress.contains(.wrap(.{ .nav_val = nav }))) { | 18422 | if (zcu.analysis_in_progress.contains(.wrap(.{ .nav_val = nav }))) { |
| 18408 | continue; | 18423 | continue; |
| 18409 | } | 18424 | } |
| 18410 | try sema.ensureNavResolved(src, nav, .fully); | 18425 | try sema.ensureNavResolved(block, src, nav, .fully); |
| 18411 | const namespace_ty = Type.fromInterned(ip.getNav(nav).status.fully_resolved.val); | 18426 | const namespace_ty = Type.fromInterned(ip.getNav(nav).status.fully_resolved.val); |
| 18412 | try sema.typeInfoNamespaceDecls(block, src, namespace_ty.getNamespaceIndex(zcu).toOptional(), declaration_ty, decl_vals, seen_namespaces); | 18427 | try sema.typeInfoNamespaceDecls(block, src, namespace_ty.getNamespaceIndex(zcu).toOptional(), declaration_ty, decl_vals, seen_namespaces); |
| 18413 | } | 18428 | } |
| ... | @@ -27932,7 +27947,7 @@ fn namespaceLookupRef( | ... | @@ -27932,7 +27947,7 @@ fn namespaceLookupRef( |
| 27932 | decl_name: InternPool.NullTerminatedString, | 27947 | decl_name: InternPool.NullTerminatedString, |
| 27933 | ) CompileError!?Air.Inst.Ref { | 27948 | ) CompileError!?Air.Inst.Ref { |
| 27934 | const nav = try sema.namespaceLookup(block, src, namespace, decl_name) orelse return null; | 27949 | const nav = try sema.namespaceLookup(block, src, namespace, decl_name) orelse return null; |
| 27935 | return try sema.analyzeNavRef(src, nav); | 27950 | return try sema.analyzeNavRef(block, src, nav); |
| 27936 | } | 27951 | } |
| 27937 | | 27952 | |
| 27938 | fn namespaceLookupVal( | 27953 | fn namespaceLookupVal( |
| ... | @@ -29095,7 +29110,7 @@ fn coerceExtra( | ... | @@ -29095,7 +29110,7 @@ fn coerceExtra( |
| 29095 | .@"extern" => |e| e.owner_nav, | 29110 | .@"extern" => |e| e.owner_nav, |
| 29096 | else => unreachable, | 29111 | else => unreachable, |
| 29097 | }; | 29112 | }; |
| 29098 | const inst_as_ptr = try sema.analyzeNavRef(inst_src, fn_nav); | 29113 | const inst_as_ptr = try sema.analyzeNavRef(block, inst_src, fn_nav); |
| 29099 | return sema.coerce(block, dest_ty, inst_as_ptr, inst_src); | 29114 | return sema.coerce(block, dest_ty, inst_as_ptr, inst_src); |
| 29100 | } | 29115 | } |
| 29101 | | 29116 | |
| ... | @@ -30748,7 +30763,7 @@ fn coerceVarArgParam( | ... | @@ -30748,7 +30763,7 @@ fn coerceVarArgParam( |
| 30748 | .@"fn" => fn_ptr: { | 30763 | .@"fn" => fn_ptr: { |
| 30749 | const fn_val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined); | 30764 | const fn_val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined); |
| 30750 | const fn_nav = zcu.funcInfo(fn_val.toIntern()).owner_nav; | 30765 | const fn_nav = zcu.funcInfo(fn_val.toIntern()).owner_nav; |
| 30751 | break :fn_ptr try sema.analyzeNavRef(inst_src, fn_nav); | 30766 | break :fn_ptr try sema.analyzeNavRef(block, inst_src, fn_nav); |
| 30752 | }, | 30767 | }, |
| 30753 | .array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}), | 30768 | .array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}), |
| 30754 | .float => float: { | 30769 | .float => float: { |
| ... | @@ -31758,12 +31773,13 @@ fn analyzeNavVal( | ... | @@ -31758,12 +31773,13 @@ fn analyzeNavVal( |
| 31758 | src: LazySrcLoc, | 31773 | src: LazySrcLoc, |
| 31759 | nav_index: InternPool.Nav.Index, | 31774 | nav_index: InternPool.Nav.Index, |
| 31760 | ) CompileError!Air.Inst.Ref { | 31775 | ) CompileError!Air.Inst.Ref { |
| 31761 | const ref = try sema.analyzeNavRefInner(src, nav_index, false); | 31776 | const ref = try sema.analyzeNavRefInner(block, src, nav_index, false); |
| 31762 | return sema.analyzeLoad(block, src, ref, src); | 31777 | return sema.analyzeLoad(block, src, ref, src); |
| 31763 | } | 31778 | } |
| 31764 | | 31779 | |
| 31765 | fn addReferenceEntry( | 31780 | fn addReferenceEntry( |
| 31766 | sema: *Sema, | 31781 | sema: *Sema, |
| | 31782 | opt_block: ?*Block, |
| 31767 | src: LazySrcLoc, | 31783 | src: LazySrcLoc, |
| 31768 | referenced_unit: AnalUnit, | 31784 | referenced_unit: AnalUnit, |
| 31769 | ) !void { | 31785 | ) !void { |
| ... | @@ -31771,10 +31787,12 @@ fn addReferenceEntry( | ... | @@ -31771,10 +31787,12 @@ fn addReferenceEntry( |
| 31771 | if (!zcu.comp.incremental and zcu.comp.reference_trace == 0) return; | 31787 | if (!zcu.comp.incremental and zcu.comp.reference_trace == 0) return; |
| 31772 | const gop = try sema.references.getOrPut(sema.gpa, referenced_unit); | 31788 | const gop = try sema.references.getOrPut(sema.gpa, referenced_unit); |
| 31773 | if (gop.found_existing) return; | 31789 | if (gop.found_existing) return; |
| 31774 | // TODO: we need to figure out how to model inline calls here. | 31790 | try zcu.addUnitReference(sema.owner, referenced_unit, src, inline_frame: { |
| 31775 | // They aren't references in the analysis sense, but ought to show up in the reference trace! | 31791 | const block = opt_block orelse break :inline_frame .none; |
| 31776 | // Would representing inline calls in the reference table cause excessive memory usage? | 31792 | const inlining = block.inlining orelse break :inline_frame .none; |
| 31777 | try zcu.addUnitReference(sema.owner, referenced_unit, src); | 31793 | const frame = try inlining.refFrame(zcu); |
| | 31794 | break :inline_frame frame.toOptional(); |
| | 31795 | }); |
| 31778 | } | 31796 | } |
| 31779 | | 31797 | |
| 31780 | pub fn addTypeReferenceEntry( | 31798 | pub fn addTypeReferenceEntry( |
| ... | @@ -31793,7 +31811,7 @@ fn ensureMemoizedStateResolved(sema: *Sema, src: LazySrcLoc, stage: InternPool.M | ... | @@ -31793,7 +31811,7 @@ fn ensureMemoizedStateResolved(sema: *Sema, src: LazySrcLoc, stage: InternPool.M |
| 31793 | const pt = sema.pt; | 31811 | const pt = sema.pt; |
| 31794 | | 31812 | |
| 31795 | const unit: AnalUnit = .wrap(.{ .memoized_state = stage }); | 31813 | const unit: AnalUnit = .wrap(.{ .memoized_state = stage }); |
| 31796 | try sema.addReferenceEntry(src, unit); | 31814 | try sema.addReferenceEntry(null, src, unit); |
| 31797 | try sema.declareDependency(.{ .memoized_state = stage }); | 31815 | try sema.declareDependency(.{ .memoized_state = stage }); |
| 31798 | | 31816 | |
| 31799 | if (pt.zcu.analysis_in_progress.contains(unit)) { | 31817 | if (pt.zcu.analysis_in_progress.contains(unit)) { |
| ... | @@ -31802,7 +31820,7 @@ fn ensureMemoizedStateResolved(sema: *Sema, src: LazySrcLoc, stage: InternPool.M | ... | @@ -31802,7 +31820,7 @@ fn ensureMemoizedStateResolved(sema: *Sema, src: LazySrcLoc, stage: InternPool.M |
| 31802 | try pt.ensureMemoizedStateUpToDate(stage); | 31820 | try pt.ensureMemoizedStateUpToDate(stage); |
| 31803 | } | 31821 | } |
| 31804 | | 31822 | |
| 31805 | pub fn ensureNavResolved(sema: *Sema, src: LazySrcLoc, nav_index: InternPool.Nav.Index, kind: enum { type, fully }) CompileError!void { | 31823 | pub fn ensureNavResolved(sema: *Sema, block: *Block, src: LazySrcLoc, nav_index: InternPool.Nav.Index, kind: enum { type, fully }) CompileError!void { |
| 31806 | const pt = sema.pt; | 31824 | const pt = sema.pt; |
| 31807 | const zcu = pt.zcu; | 31825 | const zcu = pt.zcu; |
| 31808 | const ip = &zcu.intern_pool; | 31826 | const ip = &zcu.intern_pool; |
| ... | @@ -31825,7 +31843,7 @@ pub fn ensureNavResolved(sema: *Sema, src: LazySrcLoc, nav_index: InternPool.Nav | ... | @@ -31825,7 +31843,7 @@ pub fn ensureNavResolved(sema: *Sema, src: LazySrcLoc, nav_index: InternPool.Nav |
| 31825 | .type => .{ .nav_ty = nav_index }, | 31843 | .type => .{ .nav_ty = nav_index }, |
| 31826 | .fully => .{ .nav_val = nav_index }, | 31844 | .fully => .{ .nav_val = nav_index }, |
| 31827 | }); | 31845 | }); |
| 31828 | try sema.addReferenceEntry(src, anal_unit); | 31846 | try sema.addReferenceEntry(block, src, anal_unit); |
| 31829 | | 31847 | |
| 31830 | if (zcu.analysis_in_progress.contains(anal_unit)) { | 31848 | if (zcu.analysis_in_progress.contains(anal_unit)) { |
| 31831 | return sema.failWithOwnedErrorMsg(null, try sema.errMsg(.{ | 31849 | return sema.failWithOwnedErrorMsg(null, try sema.errMsg(.{ |
| ... | @@ -31855,25 +31873,25 @@ fn optRefValue(sema: *Sema, opt_val: ?Value) !Value { | ... | @@ -31855,25 +31873,25 @@ fn optRefValue(sema: *Sema, opt_val: ?Value) !Value { |
| 31855 | } })); | 31873 | } })); |
| 31856 | } | 31874 | } |
| 31857 | | 31875 | |
| 31858 | fn analyzeNavRef(sema: *Sema, src: LazySrcLoc, nav_index: InternPool.Nav.Index) CompileError!Air.Inst.Ref { | 31876 | fn analyzeNavRef(sema: *Sema, block: *Block, src: LazySrcLoc, nav_index: InternPool.Nav.Index) CompileError!Air.Inst.Ref { |
| 31859 | return sema.analyzeNavRefInner(src, nav_index, true); | 31877 | return sema.analyzeNavRefInner(block, src, nav_index, true); |
| 31860 | } | 31878 | } |
| 31861 | | 31879 | |
| 31862 | /// Analyze a reference to the `Nav` at the given index. Ensures the underlying `Nav` is analyzed. | 31880 | /// Analyze a reference to the `Nav` at the given index. Ensures the underlying `Nav` is analyzed. |
| 31863 | /// If this pointer will be used directly, `is_ref` must be `true`. | 31881 | /// If this pointer will be used directly, `is_ref` must be `true`. |
| 31864 | /// If this pointer will be immediately loaded (i.e. a `decl_val` instruction), `is_ref` must be `false`. | 31882 | /// If this pointer will be immediately loaded (i.e. a `decl_val` instruction), `is_ref` must be `false`. |
| 31865 | fn analyzeNavRefInner(sema: *Sema, src: LazySrcLoc, orig_nav_index: InternPool.Nav.Index, is_ref: bool) CompileError!Air.Inst.Ref { | 31883 | fn analyzeNavRefInner(sema: *Sema, block: *Block, src: LazySrcLoc, orig_nav_index: InternPool.Nav.Index, is_ref: bool) CompileError!Air.Inst.Ref { |
| 31866 | const pt = sema.pt; | 31884 | const pt = sema.pt; |
| 31867 | const zcu = pt.zcu; | 31885 | const zcu = pt.zcu; |
| 31868 | const ip = &zcu.intern_pool; | 31886 | const ip = &zcu.intern_pool; |
| 31869 | | 31887 | |
| 31870 | try sema.ensureNavResolved(src, orig_nav_index, if (is_ref) .type else .fully); | 31888 | try sema.ensureNavResolved(block, src, orig_nav_index, if (is_ref) .type else .fully); |
| 31871 | | 31889 | |
| 31872 | const nav_index = nav: { | 31890 | const nav_index = nav: { |
| 31873 | if (ip.getNav(orig_nav_index).isExternOrFn(ip)) { | 31891 | if (ip.getNav(orig_nav_index).isExternOrFn(ip)) { |
| 31874 | // Getting a pointer to this `Nav` might mean we actually get a pointer to something else! | 31892 | // Getting a pointer to this `Nav` might mean we actually get a pointer to something else! |
| 31875 | // We need to resolve the value to know for sure. | 31893 | // We need to resolve the value to know for sure. |
| 31876 | if (is_ref) try sema.ensureNavResolved(src, orig_nav_index, .fully); | 31894 | if (is_ref) try sema.ensureNavResolved(block, src, orig_nav_index, .fully); |
| 31877 | switch (ip.indexToKey(ip.getNav(orig_nav_index).status.fully_resolved.val)) { | 31895 | switch (ip.indexToKey(ip.getNav(orig_nav_index).status.fully_resolved.val)) { |
| 31878 | .func => |f| break :nav f.owner_nav, | 31896 | .func => |f| break :nav f.owner_nav, |
| 31879 | .@"extern" => |e| break :nav e.owner_nav, | 31897 | .@"extern" => |e| break :nav e.owner_nav, |
| ... | @@ -31897,7 +31915,7 @@ fn analyzeNavRefInner(sema: *Sema, src: LazySrcLoc, orig_nav_index: InternPool.N | ... | @@ -31897,7 +31915,7 @@ fn analyzeNavRefInner(sema: *Sema, src: LazySrcLoc, orig_nav_index: InternPool.N |
| 31897 | }, | 31915 | }, |
| 31898 | }); | 31916 | }); |
| 31899 | if (is_ref) { | 31917 | if (is_ref) { |
| 31900 | try sema.maybeQueueFuncBodyAnalysis(src, nav_index); | 31918 | try sema.maybeQueueFuncBodyAnalysis(block, src, nav_index); |
| 31901 | } | 31919 | } |
| 31902 | return Air.internedToRef((try pt.intern(.{ .ptr = .{ | 31920 | return Air.internedToRef((try pt.intern(.{ .ptr = .{ |
| 31903 | .ty = ptr_ty.toIntern(), | 31921 | .ty = ptr_ty.toIntern(), |
| ... | @@ -31906,7 +31924,7 @@ fn analyzeNavRefInner(sema: *Sema, src: LazySrcLoc, orig_nav_index: InternPool.N | ... | @@ -31906,7 +31924,7 @@ fn analyzeNavRefInner(sema: *Sema, src: LazySrcLoc, orig_nav_index: InternPool.N |
| 31906 | } }))); | 31924 | } }))); |
| 31907 | } | 31925 | } |
| 31908 | | 31926 | |
| 31909 | fn maybeQueueFuncBodyAnalysis(sema: *Sema, src: LazySrcLoc, nav_index: InternPool.Nav.Index) !void { | 31927 | fn maybeQueueFuncBodyAnalysis(sema: *Sema, block: *Block, src: LazySrcLoc, nav_index: InternPool.Nav.Index) !void { |
| 31910 | const pt = sema.pt; | 31928 | const pt = sema.pt; |
| 31911 | const zcu = pt.zcu; | 31929 | const zcu = pt.zcu; |
| 31912 | const ip = &zcu.intern_pool; | 31930 | const ip = &zcu.intern_pool; |
| ... | @@ -31914,16 +31932,16 @@ fn maybeQueueFuncBodyAnalysis(sema: *Sema, src: LazySrcLoc, nav_index: InternPoo | ... | @@ -31914,16 +31932,16 @@ fn maybeQueueFuncBodyAnalysis(sema: *Sema, src: LazySrcLoc, nav_index: InternPoo |
| 31914 | // To avoid forcing too much resolution, let's first resolve the type, and check if it's a function. | 31932 | // To avoid forcing too much resolution, let's first resolve the type, and check if it's a function. |
| 31915 | // If it is, we can resolve the *value*, and queue analysis as needed. | 31933 | // If it is, we can resolve the *value*, and queue analysis as needed. |
| 31916 | | 31934 | |
| 31917 | try sema.ensureNavResolved(src, nav_index, .type); | 31935 | try sema.ensureNavResolved(block, src, nav_index, .type); |
| 31918 | const nav_ty: Type = .fromInterned(ip.getNav(nav_index).typeOf(ip)); | 31936 | const nav_ty: Type = .fromInterned(ip.getNav(nav_index).typeOf(ip)); |
| 31919 | if (nav_ty.zigTypeTag(zcu) != .@"fn") return; | 31937 | if (nav_ty.zigTypeTag(zcu) != .@"fn") return; |
| 31920 | if (!try nav_ty.fnHasRuntimeBitsSema(pt)) return; | 31938 | if (!try nav_ty.fnHasRuntimeBitsSema(pt)) return; |
| 31921 | | 31939 | |
| 31922 | try sema.ensureNavResolved(src, nav_index, .fully); | 31940 | try sema.ensureNavResolved(block, src, nav_index, .fully); |
| 31923 | const nav_val = zcu.navValue(nav_index); | 31941 | const nav_val = zcu.navValue(nav_index); |
| 31924 | if (!ip.isFuncBody(nav_val.toIntern())) return; | 31942 | if (!ip.isFuncBody(nav_val.toIntern())) return; |
| 31925 | | 31943 | |
| 31926 | try sema.addReferenceEntry(src, AnalUnit.wrap(.{ .func = nav_val.toIntern() })); | 31944 | try sema.addReferenceEntry(block, src, AnalUnit.wrap(.{ .func = nav_val.toIntern() })); |
| 31927 | try zcu.ensureFuncBodyAnalysisQueued(nav_val.toIntern()); | 31945 | try zcu.ensureFuncBodyAnalysisQueued(nav_val.toIntern()); |
| 31928 | } | 31946 | } |
| 31929 | | 31947 | |
| ... | @@ -31939,8 +31957,8 @@ fn analyzeRef( | ... | @@ -31939,8 +31957,8 @@ fn analyzeRef( |
| 31939 | | 31957 | |
| 31940 | if (try sema.resolveValue(operand)) |val| { | 31958 | if (try sema.resolveValue(operand)) |val| { |
| 31941 | switch (zcu.intern_pool.indexToKey(val.toIntern())) { | 31959 | switch (zcu.intern_pool.indexToKey(val.toIntern())) { |
| 31942 | .@"extern" => |e| return sema.analyzeNavRef(src, e.owner_nav), | 31960 | .@"extern" => |e| return sema.analyzeNavRef(block, src, e.owner_nav), |
| 31943 | .func => |f| return sema.analyzeNavRef(src, f.owner_nav), | 31961 | .func => |f| return sema.analyzeNavRef(block, src, f.owner_nav), |
| 31944 | else => return uavRef(sema, val.toIntern()), | 31962 | else => return uavRef(sema, val.toIntern()), |
| 31945 | } | 31963 | } |
| 31946 | } | 31964 | } |
| ... | @@ -35504,7 +35522,7 @@ fn resolveInferredErrorSet( | ... | @@ -35504,7 +35522,7 @@ fn resolveInferredErrorSet( |
| 35504 | } | 35522 | } |
| 35505 | // In this case we are dealing with the actual InferredErrorSet object that | 35523 | // In this case we are dealing with the actual InferredErrorSet object that |
| 35506 | // corresponds to the function, not one created to track an inline/comptime call. | 35524 | // corresponds to the function, not one created to track an inline/comptime call. |
| 35507 | try sema.addReferenceEntry(src, AnalUnit.wrap(.{ .func = func_index })); | 35525 | try sema.addReferenceEntry(block, src, AnalUnit.wrap(.{ .func = func_index })); |
| 35508 | try pt.ensureFuncBodyUpToDate(func_index); | 35526 | try pt.ensureFuncBodyUpToDate(func_index); |
| 35509 | } | 35527 | } |
| 35510 | | 35528 | |