aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-10-18 13:45:06 +0300
committerVeikka Tuominen <git@vexu.eu>2022-10-20 20:11:00 +0300
commitc95a34b68f6075d7a9d305d17a6b03bc9fd1fff2 (patch)
tree6e060e102426883b8b0894a0feea0dbdd0b19684 /src/Module.zig
parent34e4b07d0c3cafd0aad15b217e8c56ab9af5de40 (diff)
downloadzig-c95a34b68f6075d7a9d305d17a6b03bc9fd1fff2.tar.gz
zig-c95a34b68f6075d7a9d305d17a6b03bc9fd1fff2.zip
stage2: improve source location of assignment
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 396e92ed79..cdcf551847 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,