diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-10-21 12:11:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-21 12:11:49 +0200 |
| commit | 972c39e2c00c487a483bad002ef33ca1a5c21d02 (patch) | |
| tree | 8a5ef4ae22f2a36b020062a913c79278bfb79a30 /src/Module.zig | |
| parent | 41575b1f55b0f18d65bfeb23dc04a5489ed47b65 (diff) | |
| parent | 2609e33ab08850405682a79f60cca66c13f9a40d (diff) | |
| download | zig-972c39e2c00c487a483bad002ef33ca1a5c21d02.tar.gz zig-972c39e2c00c487a483bad002ef33ca1a5c21d02.zip | |
Merge pull request #13219 from Vexu/stage2-fixes
Stage2 bug fixes
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig index 39497fa19f..8483c41ae8 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -2878,6 +2878,32 @@ pub const SrcLoc = struct { }; return nodeToSpan(tree, full.ast.type_expr); }, + .node_offset_store_ptr => |node_off| { + const tree = try src_loc.file_scope.getTree(gpa); + const node_tags = tree.nodes.items(.tag); + const node_datas = tree.nodes.items(.data); + const node = src_loc.declRelativeToNodeIndex(node_off); + + switch (node_tags[node]) { + .assign => { + return nodeToSpan(tree, node_datas[node].lhs); + }, + else => return nodeToSpan(tree, node), + } + }, + .node_offset_store_operand => |node_off| { + const tree = try src_loc.file_scope.getTree(gpa); + const node_tags = tree.nodes.items(.tag); + const node_datas = tree.nodes.items(.data); + const node = src_loc.declRelativeToNodeIndex(node_off); + + switch (node_tags[node]) { + .assign => { + return nodeToSpan(tree, node_datas[node].rhs); + }, + else => return nodeToSpan(tree, node), + } + }, } } @@ -3213,6 +3239,12 @@ pub const LazySrcLoc = union(enum) { /// The source location points to the type of an array or struct initializer. /// The Decl is determined contextually. node_offset_init_ty: i32, + /// The source location points to the LHS of an assignment. + /// The Decl is determined contextually. + node_offset_store_ptr: i32, + /// The source location points to the RHS of an assignment. + /// The Decl is determined contextually. + node_offset_store_operand: i32, pub const nodeOffset = if (TracedOffset.want_tracing) nodeOffsetDebug else nodeOffsetRelease; @@ -3296,6 +3328,8 @@ pub const LazySrcLoc = union(enum) { .node_offset_container_tag, .node_offset_field_default, .node_offset_init_ty, + .node_offset_store_ptr, + .node_offset_store_operand, => .{ .file_scope = decl.getFileScope(), .parent_decl_node = decl.src_node, @@ -5607,6 +5641,18 @@ pub fn analyzeFnBody(mod: *Module, func: *Fn, arena: Allocator) SemaError!Air { else => |e| return e, }; + { + var it = sema.unresolved_inferred_allocs.keyIterator(); + while (it.next()) |ptr_inst| { + // The lack of a resolve_inferred_alloc means that this instruction + // is unused so it just has to be a no-op. + sema.air_instructions.set(ptr_inst.*, .{ + .tag = .alloc, + .data = .{ .ty = Type.initTag(.single_const_pointer_to_comptime_int) }, + }); + } + } + // If we don't get an error return trace from a caller, create our own. if (func.calls_or_awaits_errorable_fn and mod.comp.bin_file.options.error_return_tracing and |
