authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-03-19 12:27:20+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-03-30 20:50:48-04:00
loge409afb79bcadeabd2d5d4cc3cd5dcc54a964e94
treed09f9cc93ce8c44e5769e9124a0bd488a257345e
parent9b2345e182090e2f4c57e7684ec9739f195fdb1d

Update uses of `@fieldParentPtr` to pass a pointer type


30 files changed, 87 insertions(+), 87 deletions(-)

lib/compiler/aro/aro/pragmas/gcc.zig+6-6
......@@ -37,18 +37,18 @@ const Directive = enum {
3737};
3838
3939fn beforePreprocess(pragma: *Pragma, comp: *Compilation) void {
40 var self = @fieldParentPtr(GCC, "pragma", pragma);
40 var self = @fieldParentPtr(*GCC, "pragma", pragma);
4141 self.original_options = comp.diagnostics.options;
4242}
4343
4444fn beforeParse(pragma: *Pragma, comp: *Compilation) void {
45 var self = @fieldParentPtr(GCC, "pragma", pragma);
45 var self = @fieldParentPtr(*GCC, "pragma", pragma);
4646 comp.diagnostics.options = self.original_options;
4747 self.options_stack.items.len = 0;
4848}
4949
5050fn afterParse(pragma: *Pragma, comp: *Compilation) void {
51 var self = @fieldParentPtr(GCC, "pragma", pragma);
51 var self = @fieldParentPtr(*GCC, "pragma", pragma);
5252 comp.diagnostics.options = self.original_options;
5353 self.options_stack.items.len = 0;
5454}
......@@ -60,7 +60,7 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
6060}
6161
6262fn deinit(pragma: *Pragma, comp: *Compilation) void {
63 var self = @fieldParentPtr(GCC, "pragma", pragma);
63 var self = @fieldParentPtr(*GCC, "pragma", pragma);
6464 self.options_stack.deinit(comp.gpa);
6565 comp.gpa.destroy(self);
6666}
......@@ -108,7 +108,7 @@ fn diagnosticHandler(self: *GCC, pp: *Preprocessor, start_idx: TokenIndex) Pragm
108108}
109109
110110fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex) Pragma.Error!void {
111 var self = @fieldParentPtr(GCC, "pragma", pragma);
111 var self = @fieldParentPtr(*GCC, "pragma", pragma);
112112 const directive_tok = pp.tokens.get(start_idx + 1);
113113 if (directive_tok.id == .nl) return;
114114
......@@ -174,7 +174,7 @@ fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex
174174}
175175
176176fn parserHandler(pragma: *Pragma, p: *Parser, start_idx: TokenIndex) Compilation.Error!void {
177 var self = @fieldParentPtr(GCC, "pragma", pragma);
177 var self = @fieldParentPtr(*GCC, "pragma", pragma);
178178 const directive_tok = p.pp.tokens.get(start_idx + 1);
179179 if (directive_tok.id == .nl) return;
180180 const name = p.pp.expandedSlice(directive_tok);
lib/compiler/aro/aro/pragmas/message.zig+1-1
......@@ -22,7 +22,7 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
2222}
2323
2424fn deinit(pragma: *Pragma, comp: *Compilation) void {
25 const self = @fieldParentPtr(Message, "pragma", pragma);
25 const self = @fieldParentPtr(*Message, "pragma", pragma);
2626 comp.gpa.destroy(self);
2727}
2828
lib/compiler/aro/aro/pragmas/once.zig+3-3
......@@ -27,18 +27,18 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
2727}
2828
2929fn afterParse(pragma: *Pragma, _: *Compilation) void {
30 var self = @fieldParentPtr(Once, "pragma", pragma);
30 var self = @fieldParentPtr(*Once, "pragma", pragma);
3131 self.pragma_once.clearRetainingCapacity();
3232}
3333
3434fn deinit(pragma: *Pragma, comp: *Compilation) void {
35 var self = @fieldParentPtr(Once, "pragma", pragma);
35 var self = @fieldParentPtr(*Once, "pragma", pragma);
3636 self.pragma_once.deinit();
3737 comp.gpa.destroy(self);
3838}
3939
4040fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex) Pragma.Error!void {
41 var self = @fieldParentPtr(Once, "pragma", pragma);
41 var self = @fieldParentPtr(*Once, "pragma", pragma);
4242 const name_tok = pp.tokens.get(start_idx);
4343 const next = pp.tokens.get(start_idx + 1);
4444 if (next.id != .nl) {
lib/compiler/aro/aro/pragmas/pack.zig+2-2
......@@ -24,13 +24,13 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
2424}
2525
2626fn deinit(pragma: *Pragma, comp: *Compilation) void {
27 var self = @fieldParentPtr(Pack, "pragma", pragma);
27 var self = @fieldParentPtr(*Pack, "pragma", pragma);
2828 self.stack.deinit(comp.gpa);
2929 comp.gpa.destroy(self);
3030}
3131
3232fn parserHandler(pragma: *Pragma, p: *Parser, start_idx: TokenIndex) Compilation.Error!void {
33 var pack = @fieldParentPtr(Pack, "pragma", pragma);
33 var pack = @fieldParentPtr(*Pack, "pragma", pragma);
3434 var idx = start_idx + 1;
3535 const l_paren = p.pp.tokens.get(idx);
3636 if (l_paren.id != .l_paren) {
lib/compiler/aro_translate_c.zig+9-9
......@@ -1103,8 +1103,8 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
11031103 while (true) {
11041104 switch (scope.id) {
11051105 .root => unreachable,
1106 .block => return @fieldParentPtr(Block, "base", scope),
1107 .condition => return @fieldParentPtr(Condition, "base", scope).getBlockScope(c),
1106 .block => return @fieldParentPtr(*Block, "base", scope),
1107 .condition => return @fieldParentPtr(*Condition, "base", scope).getBlockScope(c),
11081108 else => scope = scope.parent.?,
11091109 }
11101110 }
......@@ -1116,7 +1116,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
11161116 switch (scope.id) {
11171117 .root => unreachable,
11181118 .block => {
1119 const block = @fieldParentPtr(Block, "base", scope);
1119 const block = @fieldParentPtr(*Block, "base", scope);
11201120 if (block.return_type) |ty| return ty;
11211121 scope = scope.parent.?;
11221122 },
......@@ -1128,15 +1128,15 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
11281128 pub fn getAlias(scope: *ScopeExtraScope, name: []const u8) []const u8 {
11291129 return switch (scope.id) {
11301130 .root => return name,
1131 .block => @fieldParentPtr(Block, "base", scope).getAlias(name),
1131 .block => @fieldParentPtr(*Block, "base", scope).getAlias(name),
11321132 .loop, .do_loop, .condition => scope.parent.?.getAlias(name),
11331133 };
11341134 }
11351135
11361136 pub fn contains(scope: *ScopeExtraScope, name: []const u8) bool {
11371137 return switch (scope.id) {
1138 .root => @fieldParentPtr(Root, "base", scope).contains(name),
1139 .block => @fieldParentPtr(Block, "base", scope).contains(name),
1138 .root => @fieldParentPtr(*Root, "base", scope).contains(name),
1139 .block => @fieldParentPtr(*Block, "base", scope).contains(name),
11401140 .loop, .do_loop, .condition => scope.parent.?.contains(name),
11411141 };
11421142 }
......@@ -1158,11 +1158,11 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
11581158 while (true) {
11591159 switch (scope.id) {
11601160 .root => {
1161 const root = @fieldParentPtr(Root, "base", scope);
1161 const root = @fieldParentPtr(*Root, "base", scope);
11621162 return root.nodes.append(node);
11631163 },
11641164 .block => {
1165 const block = @fieldParentPtr(Block, "base", scope);
1165 const block = @fieldParentPtr(*Block, "base", scope);
11661166 return block.statements.append(node);
11671167 },
11681168 else => scope = scope.parent.?,
......@@ -1184,7 +1184,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
11841184 switch (scope.id) {
11851185 .root => return,
11861186 .block => {
1187 const block = @fieldParentPtr(Block, "base", scope);
1187 const block = @fieldParentPtr(*Block, "base", scope);
11881188 if (block.variable_discards.get(name)) |discard| {
11891189 discard.data.should_skip = true;
11901190 return;
lib/compiler/aro_translate_c/ast.zig+8-8
......@@ -409,7 +409,7 @@ pub const Node = extern union {
409409 return null;
410410
411411 if (self.ptr_otherwise.tag == t)
412 return @fieldParentPtr(t.Type(), "base", self.ptr_otherwise);
412 return @alignCast(@fieldParentPtr(*align(1) t.Type(), "base", self.ptr_otherwise));
413413
414414 return null;
415415 }
......@@ -1220,7 +1220,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
12201220 });
12211221 },
12221222 .pub_var_simple, .var_simple => {
1223 const payload = @fieldParentPtr(Payload.SimpleVarDecl, "base", node.ptr_otherwise).data;
1223 const payload = @as(*Payload.SimpleVarDecl, @alignCast(@fieldParentPtr(*align(1) Payload.SimpleVarDecl, "base", node.ptr_otherwise))).data;
12241224 if (node.tag() == .pub_var_simple) _ = try c.addToken(.keyword_pub, "pub");
12251225 const const_tok = try c.addToken(.keyword_const, "const");
12261226 _ = try c.addIdentifier(payload.name);
......@@ -1293,7 +1293,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
12931293 },
12941294 .var_decl => return renderVar(c, node),
12951295 .arg_redecl, .alias => {
1296 const payload = @fieldParentPtr(Payload.ArgRedecl, "base", node.ptr_otherwise).data;
1296 const payload = @as(*Payload.ArgRedecl, @alignCast(@fieldParentPtr(*align(1) Payload.ArgRedecl, "base", node.ptr_otherwise))).data;
12971297 if (node.tag() == .alias) _ = try c.addToken(.keyword_pub, "pub");
12981298 const mut_tok = if (node.tag() == .alias)
12991299 try c.addToken(.keyword_const, "const")
......@@ -1492,7 +1492,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
14921492 });
14931493 },
14941494 .c_pointer, .single_pointer => {
1495 const payload = @fieldParentPtr(Payload.Pointer, "base", node.ptr_otherwise).data;
1495 const payload = @as(*Payload.Pointer, @alignCast(@fieldParentPtr(*align(1) Payload.Pointer, "base", node.ptr_otherwise))).data;
14961496
14971497 const asterisk = if (node.tag() == .single_pointer)
14981498 try c.addToken(.asterisk, "*")
......@@ -2085,7 +2085,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
20852085}
20862086
20872087fn renderRecord(c: *Context, node: Node) !NodeIndex {
2088 const payload = @fieldParentPtr(Payload.Record, "base", node.ptr_otherwise).data;
2088 const payload = @as(*Payload.Record, @alignCast(@fieldParentPtr(*align(1) Payload.Record, "base", node.ptr_otherwise))).data;
20892089 if (payload.layout == .@"packed")
20902090 _ = try c.addToken(.keyword_packed, "packed")
20912091 else if (payload.layout == .@"extern")
......@@ -2487,7 +2487,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
24872487}
24882488
24892489fn renderPrefixOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
2490 const payload = @fieldParentPtr(Payload.UnOp, "base", node.ptr_otherwise).data;
2490 const payload = @as(*Payload.UnOp, @alignCast(@fieldParentPtr(*align(1) Payload.UnOp, "base", node.ptr_otherwise))).data;
24912491 return c.addNode(.{
24922492 .tag = tag,
24932493 .main_token = try c.addToken(tok_tag, bytes),
......@@ -2499,7 +2499,7 @@ fn renderPrefixOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: T
24992499}
25002500
25012501fn renderBinOpGrouped(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
2502 const payload = @fieldParentPtr(Payload.BinOp, "base", node.ptr_otherwise).data;
2502 const payload = @as(*Payload.BinOp, @alignCast(@fieldParentPtr(*align(1) Payload.BinOp, "base", node.ptr_otherwise))).data;
25032503 const lhs = try renderNodeGrouped(c, payload.lhs);
25042504 return c.addNode(.{
25052505 .tag = tag,
......@@ -2512,7 +2512,7 @@ fn renderBinOpGrouped(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_ta
25122512}
25132513
25142514fn renderBinOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
2515 const payload = @fieldParentPtr(Payload.BinOp, "base", node.ptr_otherwise).data;
2515 const payload = @as(*Payload.BinOp, @alignCast(@fieldParentPtr(*align(1) Payload.BinOp, "base", node.ptr_otherwise))).data;
25162516 const lhs = try renderNode(c, payload.lhs);
25172517 return c.addNode(.{
25182518 .tag = tag,
lib/std/Build.zig+2-2
......@@ -1062,8 +1062,8 @@ pub fn getUninstallStep(self: *Build) *Step {
10621062
10631063fn makeUninstall(uninstall_step: *Step, prog_node: *std.Progress.Node) anyerror!void {
10641064 _ = prog_node;
1065 const uninstall_tls = @fieldParentPtr(TopLevelStep, "step", uninstall_step);
1066 const self = @fieldParentPtr(Build, "uninstall_tls", uninstall_tls);
1065 const uninstall_tls = @fieldParentPtr(*TopLevelStep, "step", uninstall_step);
1066 const self = @fieldParentPtr(*Build, "uninstall_tls", uninstall_tls);
10671067
10681068 for (self.installed_files.items) |installed_file| {
10691069 const full_path = self.getInstallPath(installed_file.dir, installed_file.path);
lib/std/Build/Step.zig+1-1
......@@ -231,7 +231,7 @@ fn makeNoOp(step: *Step, prog_node: *std.Progress.Node) anyerror!void {
231231
232232pub fn cast(step: *Step, comptime T: type) ?*T {
233233 if (step.id == T.base_id) {
234 return @fieldParentPtr(T, "step", step);
234 return @fieldParentPtr(*T, "step", step);
235235 }
236236 return null;
237237}
lib/std/Build/Step/CheckFile.zig+1-1
......@@ -49,7 +49,7 @@ pub fn setName(self: *CheckFile, name: []const u8) void {
4949fn make(step: *Step, prog_node: *std.Progress.Node) !void {
5050 _ = prog_node;
5151 const b = step.owner;
52 const self = @fieldParentPtr(CheckFile, "step", step);
52 const self = @fieldParentPtr(*CheckFile, "step", step);
5353
5454 const src_path = self.source.getPath(b);
5555 const contents = fs.cwd().readFileAlloc(b.allocator, src_path, self.max_bytes) catch |err| {
lib/std/Build/Step/CheckObject.zig+1-1
......@@ -530,7 +530,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
530530 _ = prog_node;
531531 const b = step.owner;
532532 const gpa = b.allocator;
533 const self = @fieldParentPtr(CheckObject, "step", step);
533 const self = @fieldParentPtr(*CheckObject, "step", step);
534534
535535 const src_path = self.source.getPath(b);
536536 const contents = fs.cwd().readFileAllocOptions(
lib/std/Build/Step/Compile.zig+1-1
......@@ -918,7 +918,7 @@ fn getGeneratedFilePath(self: *Compile, comptime tag_name: []const u8, asking_st
918918fn make(step: *Step, prog_node: *std.Progress.Node) !void {
919919 const b = step.owner;
920920 const arena = b.allocator;
921 const self = @fieldParentPtr(Compile, "step", step);
921 const self = @fieldParentPtr(*Compile, "step", step);
922922
923923 var zig_args = ArrayList([]const u8).init(arena);
924924 defer zig_args.deinit();
lib/std/Build/Step/ConfigHeader.zig+1-1
......@@ -167,7 +167,7 @@ fn putValue(self: *ConfigHeader, field_name: []const u8, comptime T: type, v: T)
167167fn make(step: *Step, prog_node: *std.Progress.Node) !void {
168168 _ = prog_node;
169169 const b = step.owner;
170 const self = @fieldParentPtr(ConfigHeader, "step", step);
170 const self = @fieldParentPtr(*ConfigHeader, "step", step);
171171 const gpa = b.allocator;
172172 const arena = b.allocator;
173173
lib/std/Build/Step/Fmt.zig+1-1
......@@ -47,7 +47,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
4747
4848 const b = step.owner;
4949 const arena = b.allocator;
50 const self = @fieldParentPtr(Fmt, "step", step);
50 const self = @fieldParentPtr(*Fmt, "step", step);
5151
5252 var argv: std.ArrayListUnmanaged([]const u8) = .{};
5353 try argv.ensureUnusedCapacity(arena, 2 + 1 + self.paths.len + 2 * self.exclude_paths.len);
lib/std/Build/Step/InstallArtifact.zig+1-1
......@@ -121,7 +121,7 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins
121121
122122fn make(step: *Step, prog_node: *std.Progress.Node) !void {
123123 _ = prog_node;
124 const self = @fieldParentPtr(InstallArtifact, "step", step);
124 const self = @fieldParentPtr(*InstallArtifact, "step", step);
125125 const dest_builder = step.owner;
126126 const cwd = fs.cwd();
127127
lib/std/Build/Step/InstallDir.zig+1-1
......@@ -63,7 +63,7 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {
6363
6464fn make(step: *Step, prog_node: *std.Progress.Node) !void {
6565 _ = prog_node;
66 const self = @fieldParentPtr(InstallDirStep, "step", step);
66 const self = @fieldParentPtr(*InstallDirStep, "step", step);
6767 const dest_builder = self.dest_builder;
6868 const arena = dest_builder.allocator;
6969 const dest_prefix = dest_builder.getInstallPath(self.options.install_dir, self.options.install_subdir);
lib/std/Build/Step/InstallFile.zig+1-1
......@@ -43,7 +43,7 @@ pub fn create(
4343fn make(step: *Step, prog_node: *std.Progress.Node) !void {
4444 _ = prog_node;
4545 const src_builder = step.owner;
46 const self = @fieldParentPtr(InstallFile, "step", step);
46 const self = @fieldParentPtr(*InstallFile, "step", step);
4747 const dest_builder = self.dest_builder;
4848 const full_src_path = self.source.getPath2(src_builder, step);
4949 const full_dest_path = dest_builder.getInstallPath(self.dir, self.dest_rel_path);
lib/std/Build/Step/ObjCopy.zig+1-1
......@@ -92,7 +92,7 @@ pub fn getOutputSeparatedDebug(self: *const ObjCopy) ?std.Build.LazyPath {
9292
9393fn make(step: *Step, prog_node: *std.Progress.Node) !void {
9494 const b = step.owner;
95 const self = @fieldParentPtr(ObjCopy, "step", step);
95 const self = @fieldParentPtr(*ObjCopy, "step", step);
9696
9797 var man = b.graph.cache.obtain();
9898 defer man.deinit();
lib/std/Build/Step/Options.zig+1-1
......@@ -415,7 +415,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
415415 _ = prog_node;
416416
417417 const b = step.owner;
418 const self = @fieldParentPtr(Options, "step", step);
418 const self = @fieldParentPtr(*Options, "step", step);
419419
420420 for (self.args.items) |item| {
421421 self.addOption(
lib/std/Build/Step/RemoveDir.zig+1-1
......@@ -28,7 +28,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
2828 _ = prog_node;
2929
3030 const b = step.owner;
31 const self = @fieldParentPtr(RemoveDir, "step", step);
31 const self = @fieldParentPtr(*RemoveDir, "step", step);
3232
3333 b.build_root.handle.deleteTree(self.dir_path) catch |err| {
3434 if (b.build_root.path) |base| {
lib/std/Build/Step/Run.zig+1-1
......@@ -497,7 +497,7 @@ const IndexedOutput = struct {
497497fn make(step: *Step, prog_node: *std.Progress.Node) !void {
498498 const b = step.owner;
499499 const arena = b.allocator;
500 const self = @fieldParentPtr(Run, "step", step);
500 const self = @fieldParentPtr(*Run, "step", step);
501501 const has_side_effects = self.hasSideEffects();
502502
503503 var argv_list = ArrayList([]const u8).init(arena);
lib/std/Build/Step/TranslateC.zig+1-1
......@@ -118,7 +118,7 @@ pub fn defineCMacroRaw(self: *TranslateC, name_and_value: []const u8) void {
118118
119119fn make(step: *Step, prog_node: *std.Progress.Node) !void {
120120 const b = step.owner;
121 const self = @fieldParentPtr(TranslateC, "step", step);
121 const self = @fieldParentPtr(*TranslateC, "step", step);
122122
123123 var argv_list = std.ArrayList([]const u8).init(b.allocator);
124124 try argv_list.append(b.graph.zig_exe);
lib/std/Build/Step/WriteFile.zig+1-1
......@@ -141,7 +141,7 @@ fn maybeUpdateName(wf: *WriteFile) void {
141141fn make(step: *Step, prog_node: *std.Progress.Node) !void {
142142 _ = prog_node;
143143 const b = step.owner;
144 const wf = @fieldParentPtr(WriteFile, "step", step);
144 const wf = @fieldParentPtr(*WriteFile, "step", step);
145145
146146 // Writing to source files is kind of an extra capability of this
147147 // WriteFile - arguably it should be a different step. But anyway here
lib/std/Thread/Pool.zig+2-2
......@@ -88,8 +88,8 @@ pub fn spawn(pool: *Pool, comptime func: anytype, args: anytype) !void {
8888 run_node: RunQueue.Node = .{ .data = .{ .runFn = runFn } },
8989
9090 fn runFn(runnable: *Runnable) void {
91 const run_node = @fieldParentPtr(RunQueue.Node, "data", runnable);
92 const closure = @fieldParentPtr(@This(), "run_node", run_node);
91 const run_node = @fieldParentPtr(*RunQueue.Node, "data", runnable);
92 const closure = @fieldParentPtr(*@This(), "run_node", run_node);
9393 @call(.auto, func, closure.arguments);
9494
9595 // The thread pool's allocator is protected by the mutex.
lib/std/http/Client.zig+1-1
......@@ -108,7 +108,7 @@ pub const ConnectionPool = struct {
108108 pool.mutex.lock();
109109 defer pool.mutex.unlock();
110110
111 const node = @fieldParentPtr(Node, "data", connection);
111 const node = @fieldParentPtr(*Node, "data", connection);
112112
113113 pool.used.remove(node);
114114
lib/std/zig/AstGen.zig+3-3
......@@ -11686,20 +11686,20 @@ const Scope = struct {
1168611686 fn cast(base: *Scope, comptime T: type) ?*T {
1168711687 if (T == Defer) {
1168811688 switch (base.tag) {
11689 .defer_normal, .defer_error => return @fieldParentPtr(T, "base", base),
11689 .defer_normal, .defer_error => return @alignCast(@fieldParentPtr(*align(1) T, "base", base)),
1169011690 else => return null,
1169111691 }
1169211692 }
1169311693 if (T == Namespace) {
1169411694 switch (base.tag) {
11695 .namespace => return @fieldParentPtr(T, "base", base),
11695 .namespace => return @alignCast(@fieldParentPtr(*align(1) T, "base", base)),
1169611696 else => return null,
1169711697 }
1169811698 }
1169911699 if (base.tag != T.base_tag)
1170011700 return null;
1170111701
11702 return @fieldParentPtr(T, "base", base);
11702 return @alignCast(@fieldParentPtr(*align(1) T, "base", base));
1170311703 }
1170411704
1170511705 fn parent(base: *Scope) ?*Scope {
lib/std/zig/c_translation.zig+1-1
......@@ -414,7 +414,7 @@ pub const Macros = struct {
414414 }
415415
416416 pub fn WL_CONTAINER_OF(ptr: anytype, sample: anytype, comptime member: []const u8) @TypeOf(sample) {
417 return @fieldParentPtr(@TypeOf(sample.*), member, ptr);
417 return @fieldParentPtr(@TypeOf(sample), member, ptr);
418418 }
419419
420420 /// A 2-argument function-like macro defined as #define FOO(A, B) (A)(B)
src/link.zig+23-23
......@@ -226,7 +226,7 @@ pub const File = struct {
226226 if (base.tag != T.base_tag)
227227 return null;
228228
229 return @fieldParentPtr(T, "base", base);
229 return @fieldParentPtr(*T, "base", base);
230230 }
231231
232232 pub fn makeWritable(base: *File) !void {
......@@ -383,7 +383,7 @@ pub const File = struct {
383383 .c => unreachable,
384384 .nvptx => unreachable,
385385 inline else => |t| {
386 return @fieldParentPtr(t.Type(), "base", base).lowerUnnamedConst(val, decl_index);
386 return @fieldParentPtr(*t.Type(), "base", base).lowerUnnamedConst(val, decl_index);
387387 },
388388 }
389389 }
......@@ -402,7 +402,7 @@ pub const File = struct {
402402 .c => unreachable,
403403 .nvptx => unreachable,
404404 inline else => |t| {
405 return @fieldParentPtr(t.Type(), "base", base).getGlobalSymbol(name, lib_name);
405 return @fieldParentPtr(*t.Type(), "base", base).getGlobalSymbol(name, lib_name);
406406 },
407407 }
408408 }
......@@ -413,11 +413,11 @@ pub const File = struct {
413413 assert(decl.has_tv);
414414 switch (base.tag) {
415415 .c => {
416 return @fieldParentPtr(C, "base", base).updateDecl(module, decl_index);
416 return @fieldParentPtr(*C, "base", base).updateDecl(module, decl_index);
417417 },
418418 inline else => |tag| {
419419 if (build_options.only_c) unreachable;
420 return @fieldParentPtr(tag.Type(), "base", base).updateDecl(module, decl_index);
420 return @fieldParentPtr(*tag.Type(), "base", base).updateDecl(module, decl_index);
421421 },
422422 }
423423 }
......@@ -432,11 +432,11 @@ pub const File = struct {
432432 ) UpdateDeclError!void {
433433 switch (base.tag) {
434434 .c => {
435 return @fieldParentPtr(C, "base", base).updateFunc(module, func_index, air, liveness);
435 return @fieldParentPtr(*C, "base", base).updateFunc(module, func_index, air, liveness);
436436 },
437437 inline else => |tag| {
438438 if (build_options.only_c) unreachable;
439 return @fieldParentPtr(tag.Type(), "base", base).updateFunc(module, func_index, air, liveness);
439 return @fieldParentPtr(*tag.Type(), "base", base).updateFunc(module, func_index, air, liveness);
440440 },
441441 }
442442 }
......@@ -447,11 +447,11 @@ pub const File = struct {
447447 switch (base.tag) {
448448 .spirv, .nvptx => {},
449449 .c => {
450 return @fieldParentPtr(C, "base", base).updateDeclLineNumber(module, decl_index);
450 return @fieldParentPtr(*C, "base", base).updateDeclLineNumber(module, decl_index);
451451 },
452452 inline else => |tag| {
453453 if (build_options.only_c) unreachable;
454 return @fieldParentPtr(tag.Type(), "base", base).updateDeclLineNumber(module, decl_index);
454 return @fieldParentPtr(*tag.Type(), "base", base).updateDeclLineNumber(module, decl_index);
455455 },
456456 }
457457 }
......@@ -473,11 +473,11 @@ pub const File = struct {
473473 base.releaseLock();
474474 if (base.file) |f| f.close();
475475 switch (base.tag) {
476 .c => @fieldParentPtr(C, "base", base).deinit(),
476 .c => @fieldParentPtr(*C, "base", base).deinit(),
477477
478478 inline else => |tag| {
479479 if (build_options.only_c) unreachable;
480 @fieldParentPtr(tag.Type(), "base", base).deinit();
480 @fieldParentPtr(*tag.Type(), "base", base).deinit();
481481 },
482482 }
483483 }
......@@ -560,7 +560,7 @@ pub const File = struct {
560560 pub fn flush(base: *File, arena: Allocator, prog_node: *std.Progress.Node) FlushError!void {
561561 if (build_options.only_c) {
562562 assert(base.tag == .c);
563 return @fieldParentPtr(C, "base", base).flush(arena, prog_node);
563 return @fieldParentPtr(*C, "base", base).flush(arena, prog_node);
564564 }
565565 const comp = base.comp;
566566 if (comp.clang_preprocessor_mode == .yes or comp.clang_preprocessor_mode == .pch) {
......@@ -587,7 +587,7 @@ pub const File = struct {
587587 }
588588 switch (base.tag) {
589589 inline else => |tag| {
590 return @fieldParentPtr(tag.Type(), "base", base).flush(arena, prog_node);
590 return @fieldParentPtr(*tag.Type(), "base", base).flush(arena, prog_node);
591591 },
592592 }
593593 }
......@@ -597,11 +597,11 @@ pub const File = struct {
597597 pub fn flushModule(base: *File, arena: Allocator, prog_node: *std.Progress.Node) FlushError!void {
598598 switch (base.tag) {
599599 .c => {
600 return @fieldParentPtr(C, "base", base).flushModule(arena, prog_node);
600 return @fieldParentPtr(*C, "base", base).flushModule(arena, prog_node);
601601 },
602602 inline else => |tag| {
603603 if (build_options.only_c) unreachable;
604 return @fieldParentPtr(tag.Type(), "base", base).flushModule(arena, prog_node);
604 return @fieldParentPtr(*tag.Type(), "base", base).flushModule(arena, prog_node);
605605 },
606606 }
607607 }
......@@ -610,11 +610,11 @@ pub const File = struct {
610610 pub fn freeDecl(base: *File, decl_index: InternPool.DeclIndex) void {
611611 switch (base.tag) {
612612 .c => {
613 @fieldParentPtr(C, "base", base).freeDecl(decl_index);
613 @fieldParentPtr(*C, "base", base).freeDecl(decl_index);
614614 },
615615 inline else => |tag| {
616616 if (build_options.only_c) unreachable;
617 @fieldParentPtr(tag.Type(), "base", base).freeDecl(decl_index);
617 @fieldParentPtr(*tag.Type(), "base", base).freeDecl(decl_index);
618618 },
619619 }
620620 }
......@@ -636,11 +636,11 @@ pub const File = struct {
636636 ) UpdateExportsError!void {
637637 switch (base.tag) {
638638 .c => {
639 return @fieldParentPtr(C, "base", base).updateExports(module, exported, exports);
639 return @fieldParentPtr(*C, "base", base).updateExports(module, exported, exports);
640640 },
641641 inline else => |tag| {
642642 if (build_options.only_c) unreachable;
643 return @fieldParentPtr(tag.Type(), "base", base).updateExports(module, exported, exports);
643 return @fieldParentPtr(*tag.Type(), "base", base).updateExports(module, exported, exports);
644644 },
645645 }
646646 }
......@@ -664,7 +664,7 @@ pub const File = struct {
664664 .spirv => unreachable,
665665 .nvptx => unreachable,
666666 inline else => |tag| {
667 return @fieldParentPtr(tag.Type(), "base", base).getDeclVAddr(decl_index, reloc_info);
667 return @fieldParentPtr(*tag.Type(), "base", base).getDeclVAddr(decl_index, reloc_info);
668668 },
669669 }
670670 }
......@@ -683,7 +683,7 @@ pub const File = struct {
683683 .spirv => unreachable,
684684 .nvptx => unreachable,
685685 inline else => |tag| {
686 return @fieldParentPtr(tag.Type(), "base", base).lowerAnonDecl(decl_val, decl_align, src_loc);
686 return @fieldParentPtr(*tag.Type(), "base", base).lowerAnonDecl(decl_val, decl_align, src_loc);
687687 },
688688 }
689689 }
......@@ -695,7 +695,7 @@ pub const File = struct {
695695 .spirv => unreachable,
696696 .nvptx => unreachable,
697697 inline else => |tag| {
698 return @fieldParentPtr(tag.Type(), "base", base).getAnonDeclVAddr(decl_val, reloc_info);
698 return @fieldParentPtr(*tag.Type(), "base", base).getAnonDeclVAddr(decl_val, reloc_info);
699699 },
700700 }
701701 }
......@@ -714,7 +714,7 @@ pub const File = struct {
714714 => {},
715715
716716 inline else => |tag| {
717 return @fieldParentPtr(tag.Type(), "base", base).deleteDeclExport(decl_index, name);
717 return @fieldParentPtr(*tag.Type(), "base", base).deleteDeclExport(decl_index, name);
718718 },
719719 }
720720 }
src/link/tapi/parse.zig+9-9
......@@ -35,28 +35,28 @@ pub const Node = struct {
3535 if (self.tag != T.base_tag) {
3636 return null;
3737 }
38 return @fieldParentPtr(T, "base", self);
38 return @fieldParentPtr(*const T, "base", self);
3939 }
4040
4141 pub fn deinit(self: *Node, allocator: Allocator) void {
4242 switch (self.tag) {
4343 .doc => {
44 const parent = @fieldParentPtr(Node.Doc, "base", self);
44 const parent = @fieldParentPtr(*Node.Doc, "base", self);
4545 parent.deinit(allocator);
4646 allocator.destroy(parent);
4747 },
4848 .map => {
49 const parent = @fieldParentPtr(Node.Map, "base", self);
49 const parent = @fieldParentPtr(*Node.Map, "base", self);
5050 parent.deinit(allocator);
5151 allocator.destroy(parent);
5252 },
5353 .list => {
54 const parent = @fieldParentPtr(Node.List, "base", self);
54 const parent = @fieldParentPtr(*Node.List, "base", self);
5555 parent.deinit(allocator);
5656 allocator.destroy(parent);
5757 },
5858 .value => {
59 const parent = @fieldParentPtr(Node.Value, "base", self);
59 const parent = @fieldParentPtr(*Node.Value, "base", self);
6060 parent.deinit(allocator);
6161 allocator.destroy(parent);
6262 },
......@@ -70,10 +70,10 @@ pub const Node = struct {
7070 writer: anytype,
7171 ) !void {
7272 return switch (self.tag) {
73 .doc => @fieldParentPtr(Node.Doc, "base", self).format(fmt, options, writer),
74 .map => @fieldParentPtr(Node.Map, "base", self).format(fmt, options, writer),
75 .list => @fieldParentPtr(Node.List, "base", self).format(fmt, options, writer),
76 .value => @fieldParentPtr(Node.Value, "base", self).format(fmt, options, writer),
73 .doc => @fieldParentPtr(*Node.Doc, "base", self).format(fmt, options, writer),
74 .map => @fieldParentPtr(*Node.Map, "base", self).format(fmt, options, writer),
75 .list => @fieldParentPtr(*Node.List, "base", self).format(fmt, options, writer),
76 .value => @fieldParentPtr(*Node.Value, "base", self).format(fmt, options, writer),
7777 };
7878 }
7979
src/register_manager.zig+1-1
......@@ -59,7 +59,7 @@ pub fn RegisterManager(
5959 pub const RegisterBitSet = StaticBitSet(tracked_registers.len);
6060
6161 fn getFunction(self: *Self) *Function {
62 return @fieldParentPtr(Function, "register_manager", self);
62 return @alignCast(@fieldParentPtr(*align(1) Function, "register_manager", self));
6363 }
6464
6565 fn excludeRegister(reg: Register, register_class: RegisterBitSet) bool {
test/standalone/cmakedefine/build.zig+1-1
......@@ -86,7 +86,7 @@ fn compare_headers(step: *std.Build.Step, prog_node: *std.Progress.Node) !void {
8686 const expected_fmt = "expected_{s}";
8787
8888 for (step.dependencies.items) |config_header_step| {
89 const config_header = @fieldParentPtr(ConfigHeader, "step", config_header_step);
89 const config_header = @fieldParentPtr(*ConfigHeader, "step", config_header_step);
9090
9191 const zig_header_path = config_header.output_file.path orelse @panic("Could not locate header file");
9292