authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-11-14 09:10:53+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-11-19 11:11:49+00:00
logb35589343894791a48b1423aa6d4a59b4858dfdb
tree62fb0542c4e49dd8748294bcfb75cf0c12fa5e23
parent172c2797bdd5f939e53acc26ea6820896e62733a
signature Commit is signed but in an unrecognized format.

compiler: correct unnecessary uses of 'var'


47 files changed, 210 insertions(+), 202 deletions(-)

src/Air.zig+1-1
...@@ -1787,7 +1787,7 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {...@@ -1787,7 +1787,7 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
1787 => false,1787 => false,
17881788
1789 .assembly => {1789 .assembly => {
1790 var extra = air.extraData(Air.Asm, data.ty_pl.payload);1790 const extra = air.extraData(Air.Asm, data.ty_pl.payload);
1791 const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0;1791 const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0;
1792 return is_volatile or if (extra.data.outputs_len == 1)1792 return is_volatile or if (extra.data.outputs_len == 1)
1793 @as(Air.Inst.Ref, @enumFromInt(air.extra[extra.end])) != .none1793 @as(Air.Inst.Ref, @enumFromInt(air.extra[extra.end])) != .none
src/AstGen.zig+2-2
...@@ -6707,7 +6707,7 @@ fn forExpr(...@@ -6707,7 +6707,7 @@ fn forExpr(
6707 };6707 };
6708 }6708 }
67096709
6710 var then_node = for_full.ast.then_expr;6710 const then_node = for_full.ast.then_expr;
6711 var then_scope = parent_gz.makeSubBlock(&cond_scope.base);6711 var then_scope = parent_gz.makeSubBlock(&cond_scope.base);
6712 defer then_scope.unstack();6712 defer then_scope.unstack();
67136713
...@@ -8160,7 +8160,7 @@ fn typeOf(...@@ -8160,7 +8160,7 @@ fn typeOf(
8160 }8160 }
8161 const payload_size: u32 = std.meta.fields(Zir.Inst.TypeOfPeer).len;8161 const payload_size: u32 = std.meta.fields(Zir.Inst.TypeOfPeer).len;
8162 const payload_index = try reserveExtra(astgen, payload_size + args.len);8162 const payload_index = try reserveExtra(astgen, payload_size + args.len);
8163 var args_index = payload_index + payload_size;8163 const args_index = payload_index + payload_size;
81648164
8165 const typeof_inst = try gz.addExtendedMultiOpPayloadIndex(.typeof_peer, payload_index, args.len);8165 const typeof_inst = try gz.addExtendedMultiOpPayloadIndex(.typeof_peer, payload_index, args.len);
81668166
src/Autodoc.zig+50-50
...@@ -985,7 +985,7 @@ fn walkInstruction(...@@ -985,7 +985,7 @@ fn walkInstruction(
985 },985 },
986 .import => {986 .import => {
987 const str_tok = data[@intFromEnum(inst)].str_tok;987 const str_tok = data[@intFromEnum(inst)].str_tok;
988 var path = str_tok.get(file.zir);988 const path = str_tok.get(file.zir);
989989
990 // importFile cannot error out since all files990 // importFile cannot error out since all files
991 // are already loaded at this point991 // are already loaded at this point
...@@ -1210,7 +1210,7 @@ fn walkInstruction(...@@ -1210,7 +1210,7 @@ fn walkInstruction(
1210 .compile_error => {1210 .compile_error => {
1211 const un_node = data[@intFromEnum(inst)].un_node;1211 const un_node = data[@intFromEnum(inst)].un_node;
12121212
1213 var operand: DocData.WalkResult = try self.walkRef(1213 const operand: DocData.WalkResult = try self.walkRef(
1214 file,1214 file,
1215 parent_scope,1215 parent_scope,
1216 parent_src,1216 parent_src,
...@@ -1252,7 +1252,7 @@ fn walkInstruction(...@@ -1252,7 +1252,7 @@ fn walkInstruction(
1252 const byte_count = str.len * @sizeOf(std.math.big.Limb);1252 const byte_count = str.len * @sizeOf(std.math.big.Limb);
1253 const limb_bytes = file.zir.string_bytes[str.start..][0..byte_count];1253 const limb_bytes = file.zir.string_bytes[str.start..][0..byte_count];
12541254
1255 var limbs = try self.arena.alloc(std.math.big.Limb, str.len);1255 const limbs = try self.arena.alloc(std.math.big.Limb, str.len);
1256 @memcpy(std.mem.sliceAsBytes(limbs)[0..limb_bytes.len], limb_bytes);1256 @memcpy(std.mem.sliceAsBytes(limbs)[0..limb_bytes.len], limb_bytes);
12571257
1258 const big_int = std.math.big.int.Const{1258 const big_int = std.math.big.int.Const{
...@@ -1281,7 +1281,7 @@ fn walkInstruction(...@@ -1281,7 +1281,7 @@ fn walkInstruction(
1281 const slice_index = self.exprs.items.len;1281 const slice_index = self.exprs.items.len;
1282 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });1282 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });
12831283
1284 var lhs: DocData.WalkResult = try self.walkRef(1284 const lhs: DocData.WalkResult = try self.walkRef(
1285 file,1285 file,
1286 parent_scope,1286 parent_scope,
1287 parent_src,1287 parent_src,
...@@ -1289,7 +1289,7 @@ fn walkInstruction(...@@ -1289,7 +1289,7 @@ fn walkInstruction(
1289 false,1289 false,
1290 call_ctx,1290 call_ctx,
1291 );1291 );
1292 var start: DocData.WalkResult = try self.walkRef(1292 const start: DocData.WalkResult = try self.walkRef(
1293 file,1293 file,
1294 parent_scope,1294 parent_scope,
1295 parent_src,1295 parent_src,
...@@ -1321,7 +1321,7 @@ fn walkInstruction(...@@ -1321,7 +1321,7 @@ fn walkInstruction(
1321 const slice_index = self.exprs.items.len;1321 const slice_index = self.exprs.items.len;
1322 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });1322 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });
13231323
1324 var lhs: DocData.WalkResult = try self.walkRef(1324 const lhs: DocData.WalkResult = try self.walkRef(
1325 file,1325 file,
1326 parent_scope,1326 parent_scope,
1327 parent_src,1327 parent_src,
...@@ -1329,7 +1329,7 @@ fn walkInstruction(...@@ -1329,7 +1329,7 @@ fn walkInstruction(
1329 false,1329 false,
1330 call_ctx,1330 call_ctx,
1331 );1331 );
1332 var start: DocData.WalkResult = try self.walkRef(1332 const start: DocData.WalkResult = try self.walkRef(
1333 file,1333 file,
1334 parent_scope,1334 parent_scope,
1335 parent_src,1335 parent_src,
...@@ -1337,7 +1337,7 @@ fn walkInstruction(...@@ -1337,7 +1337,7 @@ fn walkInstruction(
1337 false,1337 false,
1338 call_ctx,1338 call_ctx,
1339 );1339 );
1340 var end: DocData.WalkResult = try self.walkRef(1340 const end: DocData.WalkResult = try self.walkRef(
1341 file,1341 file,
1342 parent_scope,1342 parent_scope,
1343 parent_src,1343 parent_src,
...@@ -1371,7 +1371,7 @@ fn walkInstruction(...@@ -1371,7 +1371,7 @@ fn walkInstruction(
1371 const slice_index = self.exprs.items.len;1371 const slice_index = self.exprs.items.len;
1372 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });1372 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });
13731373
1374 var lhs: DocData.WalkResult = try self.walkRef(1374 const lhs: DocData.WalkResult = try self.walkRef(
1375 file,1375 file,
1376 parent_scope,1376 parent_scope,
1377 parent_src,1377 parent_src,
...@@ -1379,7 +1379,7 @@ fn walkInstruction(...@@ -1379,7 +1379,7 @@ fn walkInstruction(
1379 false,1379 false,
1380 call_ctx,1380 call_ctx,
1381 );1381 );
1382 var start: DocData.WalkResult = try self.walkRef(1382 const start: DocData.WalkResult = try self.walkRef(
1383 file,1383 file,
1384 parent_scope,1384 parent_scope,
1385 parent_src,1385 parent_src,
...@@ -1387,7 +1387,7 @@ fn walkInstruction(...@@ -1387,7 +1387,7 @@ fn walkInstruction(
1387 false,1387 false,
1388 call_ctx,1388 call_ctx,
1389 );1389 );
1390 var end: DocData.WalkResult = try self.walkRef(1390 const end: DocData.WalkResult = try self.walkRef(
1391 file,1391 file,
1392 parent_scope,1392 parent_scope,
1393 parent_src,1393 parent_src,
...@@ -1395,7 +1395,7 @@ fn walkInstruction(...@@ -1395,7 +1395,7 @@ fn walkInstruction(
1395 false,1395 false,
1396 call_ctx,1396 call_ctx,
1397 );1397 );
1398 var sentinel: DocData.WalkResult = try self.walkRef(1398 const sentinel: DocData.WalkResult = try self.walkRef(
1399 file,1399 file,
1400 parent_scope,1400 parent_scope,
1401 parent_src,1401 parent_src,
...@@ -1436,7 +1436,7 @@ fn walkInstruction(...@@ -1436,7 +1436,7 @@ fn walkInstruction(
1436 const slice_index = self.exprs.items.len;1436 const slice_index = self.exprs.items.len;
1437 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });1437 try self.exprs.append(self.arena, .{ .slice = .{ .lhs = 0, .start = 0 } });
14381438
1439 var lhs: DocData.WalkResult = try self.walkRef(1439 const lhs: DocData.WalkResult = try self.walkRef(
1440 file,1440 file,
1441 parent_scope,1441 parent_scope,
1442 parent_src,1442 parent_src,
...@@ -1444,7 +1444,7 @@ fn walkInstruction(...@@ -1444,7 +1444,7 @@ fn walkInstruction(
1444 false,1444 false,
1445 call_ctx,1445 call_ctx,
1446 );1446 );
1447 var start: DocData.WalkResult = try self.walkRef(1447 const start: DocData.WalkResult = try self.walkRef(
1448 file,1448 file,
1449 parent_scope,1449 parent_scope,
1450 parent_src,1450 parent_src,
...@@ -1452,7 +1452,7 @@ fn walkInstruction(...@@ -1452,7 +1452,7 @@ fn walkInstruction(
1452 false,1452 false,
1453 call_ctx,1453 call_ctx,
1454 );1454 );
1455 var len: DocData.WalkResult = try self.walkRef(1455 const len: DocData.WalkResult = try self.walkRef(
1456 file,1456 file,
1457 parent_scope,1457 parent_scope,
1458 parent_src,1458 parent_src,
...@@ -1460,7 +1460,7 @@ fn walkInstruction(...@@ -1460,7 +1460,7 @@ fn walkInstruction(
1460 false,1460 false,
1461 call_ctx,1461 call_ctx,
1462 );1462 );
1463 var sentinel_opt: ?DocData.WalkResult = if (extra.data.sentinel != .none)1463 const sentinel_opt: ?DocData.WalkResult = if (extra.data.sentinel != .none)
1464 try self.walkRef(1464 try self.walkRef(
1465 file,1465 file,
1466 parent_scope,1466 parent_scope,
...@@ -1574,7 +1574,7 @@ fn walkInstruction(...@@ -1574,7 +1574,7 @@ fn walkInstruction(
1574 const binop_index = self.exprs.items.len;1574 const binop_index = self.exprs.items.len;
1575 try self.exprs.append(self.arena, .{ .binOp = .{ .lhs = 0, .rhs = 0 } });1575 try self.exprs.append(self.arena, .{ .binOp = .{ .lhs = 0, .rhs = 0 } });
15761576
1577 var lhs: DocData.WalkResult = try self.walkRef(1577 const lhs: DocData.WalkResult = try self.walkRef(
1578 file,1578 file,
1579 parent_scope,1579 parent_scope,
1580 parent_src,1580 parent_src,
...@@ -1582,7 +1582,7 @@ fn walkInstruction(...@@ -1582,7 +1582,7 @@ fn walkInstruction(
1582 false,1582 false,
1583 call_ctx,1583 call_ctx,
1584 );1584 );
1585 var rhs: DocData.WalkResult = try self.walkRef(1585 const rhs: DocData.WalkResult = try self.walkRef(
1586 file,1586 file,
1587 parent_scope,1587 parent_scope,
1588 parent_src,1588 parent_src,
...@@ -1620,7 +1620,7 @@ fn walkInstruction(...@@ -1620,7 +1620,7 @@ fn walkInstruction(
1620 const binop_index = self.exprs.items.len;1620 const binop_index = self.exprs.items.len;
1621 try self.exprs.append(self.arena, .{ .binOp = .{ .lhs = 0, .rhs = 0 } });1621 try self.exprs.append(self.arena, .{ .binOp = .{ .lhs = 0, .rhs = 0 } });
16221622
1623 var lhs: DocData.WalkResult = try self.walkRef(1623 const lhs: DocData.WalkResult = try self.walkRef(
1624 file,1624 file,
1625 parent_scope,1625 parent_scope,
1626 parent_src,1626 parent_src,
...@@ -1628,7 +1628,7 @@ fn walkInstruction(...@@ -1628,7 +1628,7 @@ fn walkInstruction(
1628 false,1628 false,
1629 call_ctx,1629 call_ctx,
1630 );1630 );
1631 var rhs: DocData.WalkResult = try self.walkRef(1631 const rhs: DocData.WalkResult = try self.walkRef(
1632 file,1632 file,
1633 parent_scope,1633 parent_scope,
1634 parent_src,1634 parent_src,
...@@ -1786,7 +1786,7 @@ fn walkInstruction(...@@ -1786,7 +1786,7 @@ fn walkInstruction(
1786 const pl_node = data[@intFromEnum(inst)].pl_node;1786 const pl_node = data[@intFromEnum(inst)].pl_node;
1787 const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index);1787 const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index);
17881788
1789 var rhs: DocData.WalkResult = try self.walkRef(1789 const rhs: DocData.WalkResult = try self.walkRef(
1790 file,1790 file,
1791 parent_scope,1791 parent_scope,
1792 parent_src,1792 parent_src,
...@@ -1801,7 +1801,7 @@ fn walkInstruction(...@@ -1801,7 +1801,7 @@ fn walkInstruction(
1801 const rhs_index = self.exprs.items.len;1801 const rhs_index = self.exprs.items.len;
1802 try self.exprs.append(self.arena, rhs.expr);1802 try self.exprs.append(self.arena, rhs.expr);
18031803
1804 var lhs: DocData.WalkResult = try self.walkRef(1804 const lhs: DocData.WalkResult = try self.walkRef(
1805 file,1805 file,
1806 parent_scope,1806 parent_scope,
1807 parent_src,1807 parent_src,
...@@ -1850,7 +1850,7 @@ fn walkInstruction(...@@ -1850,7 +1850,7 @@ fn walkInstruction(
1850 const binop_index = self.exprs.items.len;1850 const binop_index = self.exprs.items.len;
1851 try self.exprs.append(self.arena, .{ .builtinBin = .{ .lhs = 0, .rhs = 0 } });1851 try self.exprs.append(self.arena, .{ .builtinBin = .{ .lhs = 0, .rhs = 0 } });
18521852
1853 var lhs: DocData.WalkResult = try self.walkRef(1853 const lhs: DocData.WalkResult = try self.walkRef(
1854 file,1854 file,
1855 parent_scope,1855 parent_scope,
1856 parent_src,1856 parent_src,
...@@ -1858,7 +1858,7 @@ fn walkInstruction(...@@ -1858,7 +1858,7 @@ fn walkInstruction(
1858 false,1858 false,
1859 call_ctx,1859 call_ctx,
1860 );1860 );
1861 var rhs: DocData.WalkResult = try self.walkRef(1861 const rhs: DocData.WalkResult = try self.walkRef(
1862 file,1862 file,
1863 parent_scope,1863 parent_scope,
1864 parent_src,1864 parent_src,
...@@ -1882,7 +1882,7 @@ fn walkInstruction(...@@ -1882,7 +1882,7 @@ fn walkInstruction(
1882 const pl_node = data[@intFromEnum(inst)].pl_node;1882 const pl_node = data[@intFromEnum(inst)].pl_node;
1883 const extra = file.zir.extraData(Zir.Inst.MulAdd, pl_node.payload_index);1883 const extra = file.zir.extraData(Zir.Inst.MulAdd, pl_node.payload_index);
18841884
1885 var mul1: DocData.WalkResult = try self.walkRef(1885 const mul1: DocData.WalkResult = try self.walkRef(
1886 file,1886 file,
1887 parent_scope,1887 parent_scope,
1888 parent_src,1888 parent_src,
...@@ -1890,7 +1890,7 @@ fn walkInstruction(...@@ -1890,7 +1890,7 @@ fn walkInstruction(
1890 false,1890 false,
1891 call_ctx,1891 call_ctx,
1892 );1892 );
1893 var mul2: DocData.WalkResult = try self.walkRef(1893 const mul2: DocData.WalkResult = try self.walkRef(
1894 file,1894 file,
1895 parent_scope,1895 parent_scope,
1896 parent_src,1896 parent_src,
...@@ -1898,7 +1898,7 @@ fn walkInstruction(...@@ -1898,7 +1898,7 @@ fn walkInstruction(
1898 false,1898 false,
1899 call_ctx,1899 call_ctx,
1900 );1900 );
1901 var add: DocData.WalkResult = try self.walkRef(1901 const add: DocData.WalkResult = try self.walkRef(
1902 file,1902 file,
1903 parent_scope,1903 parent_scope,
1904 parent_src,1904 parent_src,
...@@ -1914,7 +1914,7 @@ fn walkInstruction(...@@ -1914,7 +1914,7 @@ fn walkInstruction(
1914 const add_index = self.exprs.items.len;1914 const add_index = self.exprs.items.len;
1915 try self.exprs.append(self.arena, add.expr);1915 try self.exprs.append(self.arena, add.expr);
19161916
1917 var type_index: usize = self.exprs.items.len;1917 const type_index: usize = self.exprs.items.len;
1918 try self.exprs.append(self.arena, add.typeRef orelse .{ .type = @intFromEnum(Ref.type_type) });1918 try self.exprs.append(self.arena, add.typeRef orelse .{ .type = @intFromEnum(Ref.type_type) });
19191919
1920 return DocData.WalkResult{1920 return DocData.WalkResult{
...@@ -1933,7 +1933,7 @@ fn walkInstruction(...@@ -1933,7 +1933,7 @@ fn walkInstruction(
1933 const pl_node = data[@intFromEnum(inst)].pl_node;1933 const pl_node = data[@intFromEnum(inst)].pl_node;
1934 const extra = file.zir.extraData(Zir.Inst.UnionInit, pl_node.payload_index);1934 const extra = file.zir.extraData(Zir.Inst.UnionInit, pl_node.payload_index);
19351935
1936 var union_type: DocData.WalkResult = try self.walkRef(1936 const union_type: DocData.WalkResult = try self.walkRef(
1937 file,1937 file,
1938 parent_scope,1938 parent_scope,
1939 parent_src,1939 parent_src,
...@@ -1941,7 +1941,7 @@ fn walkInstruction(...@@ -1941,7 +1941,7 @@ fn walkInstruction(
1941 false,1941 false,
1942 call_ctx,1942 call_ctx,
1943 );1943 );
1944 var field_name: DocData.WalkResult = try self.walkRef(1944 const field_name: DocData.WalkResult = try self.walkRef(
1945 file,1945 file,
1946 parent_scope,1946 parent_scope,
1947 parent_src,1947 parent_src,
...@@ -1949,7 +1949,7 @@ fn walkInstruction(...@@ -1949,7 +1949,7 @@ fn walkInstruction(
1949 false,1949 false,
1950 call_ctx,1950 call_ctx,
1951 );1951 );
1952 var init: DocData.WalkResult = try self.walkRef(1952 const init: DocData.WalkResult = try self.walkRef(
1953 file,1953 file,
1954 parent_scope,1954 parent_scope,
1955 parent_src,1955 parent_src,
...@@ -1980,7 +1980,7 @@ fn walkInstruction(...@@ -1980,7 +1980,7 @@ fn walkInstruction(
1980 const pl_node = data[@intFromEnum(inst)].pl_node;1980 const pl_node = data[@intFromEnum(inst)].pl_node;
1981 const extra = file.zir.extraData(Zir.Inst.BuiltinCall, pl_node.payload_index);1981 const extra = file.zir.extraData(Zir.Inst.BuiltinCall, pl_node.payload_index);
19821982
1983 var modifier: DocData.WalkResult = try self.walkRef(1983 const modifier: DocData.WalkResult = try self.walkRef(
1984 file,1984 file,
1985 parent_scope,1985 parent_scope,
1986 parent_src,1986 parent_src,
...@@ -1989,7 +1989,7 @@ fn walkInstruction(...@@ -1989,7 +1989,7 @@ fn walkInstruction(
1989 call_ctx,1989 call_ctx,
1990 );1990 );
19911991
1992 var callee: DocData.WalkResult = try self.walkRef(1992 const callee: DocData.WalkResult = try self.walkRef(
1993 file,1993 file,
1994 parent_scope,1994 parent_scope,
1995 parent_src,1995 parent_src,
...@@ -1998,7 +1998,7 @@ fn walkInstruction(...@@ -1998,7 +1998,7 @@ fn walkInstruction(
1998 call_ctx,1998 call_ctx,
1999 );1999 );
20002000
2001 var args: DocData.WalkResult = try self.walkRef(2001 const args: DocData.WalkResult = try self.walkRef(
2002 file,2002 file,
2003 parent_scope,2003 parent_scope,
2004 parent_src,2004 parent_src,
...@@ -2028,7 +2028,7 @@ fn walkInstruction(...@@ -2028,7 +2028,7 @@ fn walkInstruction(
2028 const pl_node = data[@intFromEnum(inst)].pl_node;2028 const pl_node = data[@intFromEnum(inst)].pl_node;
2029 const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index);2029 const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index);
20302030
2031 var lhs: DocData.WalkResult = try self.walkRef(2031 const lhs: DocData.WalkResult = try self.walkRef(
2032 file,2032 file,
2033 parent_scope,2033 parent_scope,
2034 parent_src,2034 parent_src,
...@@ -2036,7 +2036,7 @@ fn walkInstruction(...@@ -2036,7 +2036,7 @@ fn walkInstruction(
2036 false,2036 false,
2037 call_ctx,2037 call_ctx,
2038 );2038 );
2039 var rhs: DocData.WalkResult = try self.walkRef(2039 const rhs: DocData.WalkResult = try self.walkRef(
2040 file,2040 file,
2041 parent_scope,2041 parent_scope,
2042 parent_src,2042 parent_src,
...@@ -2060,7 +2060,7 @@ fn walkInstruction(...@@ -2060,7 +2060,7 @@ fn walkInstruction(
2060 const pl_node = data[@intFromEnum(inst)].pl_node;2060 const pl_node = data[@intFromEnum(inst)].pl_node;
2061 const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index);2061 const extra = file.zir.extraData(Zir.Inst.Bin, pl_node.payload_index);
20622062
2063 var lhs: DocData.WalkResult = try self.walkRef(2063 const lhs: DocData.WalkResult = try self.walkRef(
2064 file,2064 file,
2065 parent_scope,2065 parent_scope,
2066 parent_src,2066 parent_src,
...@@ -2068,7 +2068,7 @@ fn walkInstruction(...@@ -2068,7 +2068,7 @@ fn walkInstruction(
2068 false,2068 false,
2069 call_ctx,2069 call_ctx,
2070 );2070 );
2071 var rhs: DocData.WalkResult = try self.walkRef(2071 const rhs: DocData.WalkResult = try self.walkRef(
2072 file,2072 file,
2073 parent_scope,2073 parent_scope,
2074 parent_src,2074 parent_src,
...@@ -2090,7 +2090,7 @@ fn walkInstruction(...@@ -2090,7 +2090,7 @@ fn walkInstruction(
2090 // .elem_type => {2090 // .elem_type => {
2091 // const un_node = data[@intFromEnum(inst)].un_node;2091 // const un_node = data[@intFromEnum(inst)].un_node;
20922092
2093 // var operand: DocData.WalkResult = try self.walkRef(2093 // const operand: DocData.WalkResult = try self.walkRef(
2094 // file,2094 // file,
2095 // parent_scope, parent_src,2095 // parent_scope, parent_src,
2096 // un_node.operand,2096 // un_node.operand,
...@@ -2158,7 +2158,7 @@ fn walkInstruction(...@@ -2158,7 +2158,7 @@ fn walkInstruction(
2158 address_space = ref_result.expr;2158 address_space = ref_result.expr;
2159 extra_index += 1;2159 extra_index += 1;
2160 }2160 }
2161 var bit_start: ?DocData.Expr = null;2161 const bit_start: ?DocData.Expr = null;
2162 if (ptr.flags.has_bit_range) {2162 if (ptr.flags.has_bit_range) {
2163 const ref = @as(Zir.Inst.Ref, @enumFromInt(file.zir.extra[extra_index]));2163 const ref = @as(Zir.Inst.Ref, @enumFromInt(file.zir.extra[extra_index]));
2164 const ref_result = try self.walkRef(2164 const ref_result = try self.walkRef(
...@@ -2292,7 +2292,7 @@ fn walkInstruction(...@@ -2292,7 +2292,7 @@ fn walkInstruction(
2292 const array_data = try self.arena.alloc(usize, operands.len - 1);2292 const array_data = try self.arena.alloc(usize, operands.len - 1);
22932293
2294 std.debug.assert(operands.len > 0);2294 std.debug.assert(operands.len > 0);
2295 var array_type = try self.walkRef(2295 const array_type = try self.walkRef(
2296 file,2296 file,
2297 parent_scope,2297 parent_scope,
2298 parent_src,2298 parent_src,
...@@ -2352,7 +2352,7 @@ fn walkInstruction(...@@ -2352,7 +2352,7 @@ fn walkInstruction(
2352 const array_data = try self.arena.alloc(usize, operands.len - 1);2352 const array_data = try self.arena.alloc(usize, operands.len - 1);
23532353
2354 std.debug.assert(operands.len > 0);2354 std.debug.assert(operands.len > 0);
2355 var array_type = try self.walkRef(2355 const array_type = try self.walkRef(
2356 file,2356 file,
2357 parent_scope,2357 parent_scope,
2358 parent_src,2358 parent_src,
...@@ -2578,7 +2578,7 @@ fn walkInstruction(...@@ -2578,7 +2578,7 @@ fn walkInstruction(
2578 const pl_node = data[@intFromEnum(inst)].pl_node;2578 const pl_node = data[@intFromEnum(inst)].pl_node;
2579 const extra = file.zir.extraData(Zir.Inst.Block, pl_node.payload_index);2579 const extra = file.zir.extraData(Zir.Inst.Block, pl_node.payload_index);
2580 const body = file.zir.extra[extra.end..][extra.data.body_len - 1];2580 const body = file.zir.extra[extra.end..][extra.data.body_len - 1];
2581 var operand: DocData.WalkResult = try self.walkRef(2581 const operand: DocData.WalkResult = try self.walkRef(
2582 file,2582 file,
2583 parent_scope,2583 parent_scope,
2584 parent_src,2584 parent_src,
...@@ -2903,7 +2903,7 @@ fn walkInstruction(...@@ -2903,7 +2903,7 @@ fn walkInstruction(
2903 => {2903 => {
2904 const un_node = data[@intFromEnum(inst)].un_node;2904 const un_node = data[@intFromEnum(inst)].un_node;
29052905
2906 var operand: DocData.WalkResult = try self.walkRef(2906 const operand: DocData.WalkResult = try self.walkRef(
2907 file,2907 file,
2908 parent_scope,2908 parent_scope,
2909 parent_src,2909 parent_src,
...@@ -2920,7 +2920,7 @@ fn walkInstruction(...@@ -2920,7 +2920,7 @@ fn walkInstruction(
2920 .struct_init_empty_ref_result => {2920 .struct_init_empty_ref_result => {
2921 const un_node = data[@intFromEnum(inst)].un_node;2921 const un_node = data[@intFromEnum(inst)].un_node;
29222922
2923 var operand: DocData.WalkResult = try self.walkRef(2923 const operand: DocData.WalkResult = try self.walkRef(
2924 file,2924 file,
2925 parent_scope,2925 parent_scope,
2926 parent_src,2926 parent_src,
...@@ -3937,7 +3937,7 @@ fn walkInstruction(...@@ -3937,7 +3937,7 @@ fn walkInstruction(
3937 try self.exprs.append(self.arena, last_type);3937 try self.exprs.append(self.arena, last_type);
39383938
3939 const ptr_index = self.exprs.items.len;3939 const ptr_index = self.exprs.items.len;
3940 var ptr: DocData.WalkResult = try self.walkRef(3940 const ptr: DocData.WalkResult = try self.walkRef(
3941 file,3941 file,
3942 parent_scope,3942 parent_scope,
3943 parent_src,3943 parent_src,
...@@ -3948,7 +3948,7 @@ fn walkInstruction(...@@ -3948,7 +3948,7 @@ fn walkInstruction(
3948 try self.exprs.append(self.arena, ptr.expr);3948 try self.exprs.append(self.arena, ptr.expr);
39493949
3950 const expected_value_index = self.exprs.items.len;3950 const expected_value_index = self.exprs.items.len;
3951 var expected_value: DocData.WalkResult = try self.walkRef(3951 const expected_value: DocData.WalkResult = try self.walkRef(
3952 file,3952 file,
3953 parent_scope,3953 parent_scope,
3954 parent_src,3954 parent_src,
...@@ -3959,7 +3959,7 @@ fn walkInstruction(...@@ -3959,7 +3959,7 @@ fn walkInstruction(
3959 try self.exprs.append(self.arena, expected_value.expr);3959 try self.exprs.append(self.arena, expected_value.expr);
39603960
3961 const new_value_index = self.exprs.items.len;3961 const new_value_index = self.exprs.items.len;
3962 var new_value: DocData.WalkResult = try self.walkRef(3962 const new_value: DocData.WalkResult = try self.walkRef(
3963 file,3963 file,
3964 parent_scope,3964 parent_scope,
3965 parent_src,3965 parent_src,
...@@ -3970,7 +3970,7 @@ fn walkInstruction(...@@ -3970,7 +3970,7 @@ fn walkInstruction(
3970 try self.exprs.append(self.arena, new_value.expr);3970 try self.exprs.append(self.arena, new_value.expr);
39713971
3972 const success_order_index = self.exprs.items.len;3972 const success_order_index = self.exprs.items.len;
3973 var success_order: DocData.WalkResult = try self.walkRef(3973 const success_order: DocData.WalkResult = try self.walkRef(
3974 file,3974 file,
3975 parent_scope,3975 parent_scope,
3976 parent_src,3976 parent_src,
...@@ -3981,7 +3981,7 @@ fn walkInstruction(...@@ -3981,7 +3981,7 @@ fn walkInstruction(
3981 try self.exprs.append(self.arena, success_order.expr);3981 try self.exprs.append(self.arena, success_order.expr);
39823982
3983 const failure_order_index = self.exprs.items.len;3983 const failure_order_index = self.exprs.items.len;
3984 var failure_order: DocData.WalkResult = try self.walkRef(3984 const failure_order: DocData.WalkResult = try self.walkRef(
3985 file,3985 file,
3986 parent_scope,3986 parent_scope,
3987 parent_src,3987 parent_src,
src/Compilation.zig+6-6
...@@ -1759,7 +1759,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1759,7 +1759,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
17591759
1760 const digest = hash.final();1760 const digest = hash.final();
1761 const artifact_sub_dir = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest });1761 const artifact_sub_dir = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest });
1762 var artifact_dir = try options.local_cache_directory.handle.makeOpenPath(artifact_sub_dir, .{});1762 const artifact_dir = try options.local_cache_directory.handle.makeOpenPath(artifact_sub_dir, .{});
1763 owned_link_dir = artifact_dir;1763 owned_link_dir = artifact_dir;
1764 const link_artifact_directory: Directory = .{1764 const link_artifact_directory: Directory = .{
1765 .handle = artifact_dir,1765 .handle = artifact_dir,
...@@ -2173,7 +2173,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -2173,7 +2173,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
2173 // LLD might drop some symbols as unused during LTO and GCing, therefore,2173 // LLD might drop some symbols as unused during LTO and GCing, therefore,
2174 // we force mark them for resolution here.2174 // we force mark them for resolution here.
21752175
2176 var tls_index_sym = switch (comp.getTarget().cpu.arch) {2176 const tls_index_sym = switch (comp.getTarget().cpu.arch) {
2177 .x86 => "__tls_index",2177 .x86 => "__tls_index",
2178 else => "_tls_index",2178 else => "_tls_index",
2179 };2179 };
...@@ -2576,7 +2576,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void...@@ -2576,7 +2576,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
2576 var artifact_dir = try comp.local_cache_directory.handle.openDir(o_sub_path, .{});2576 var artifact_dir = try comp.local_cache_directory.handle.openDir(o_sub_path, .{});
2577 defer artifact_dir.close();2577 defer artifact_dir.close();
25782578
2579 var dir_path = try comp.local_cache_directory.join(comp.gpa, &.{o_sub_path});2579 const dir_path = try comp.local_cache_directory.join(comp.gpa, &.{o_sub_path});
2580 defer comp.gpa.free(dir_path);2580 defer comp.gpa.free(dir_path);
25812581
2582 module.zig_cache_artifact_directory = .{2582 module.zig_cache_artifact_directory = .{
...@@ -4961,7 +4961,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -4961,7 +4961,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
49614961
4962 var cli_diagnostics = resinator.cli.Diagnostics.init(comp.gpa);4962 var cli_diagnostics = resinator.cli.Diagnostics.init(comp.gpa);
4963 defer cli_diagnostics.deinit();4963 defer cli_diagnostics.deinit();
4964 var options = resinator.cli.parse(comp.gpa, resinator_args.items, &cli_diagnostics) catch |err| switch (err) {4964 const options = resinator.cli.parse(comp.gpa, resinator_args.items, &cli_diagnostics) catch |err| switch (err) {
4965 error.ParseError => {4965 error.ParseError => {
4966 return comp.failWin32ResourceCli(win32_resource, &cli_diagnostics);4966 return comp.failWin32ResourceCli(win32_resource, &cli_diagnostics);
4967 },4967 },
...@@ -5062,7 +5062,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -5062,7 +5062,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
5062 log.warn("failed to delete '{s}': {s}", .{ out_dep_path, @errorName(err) });5062 log.warn("failed to delete '{s}': {s}", .{ out_dep_path, @errorName(err) });
5063 };5063 };
50645064
5065 var full_input = std.fs.cwd().readFileAlloc(arena, out_rcpp_path, std.math.maxInt(usize)) catch |err| switch (err) {5065 const full_input = std.fs.cwd().readFileAlloc(arena, out_rcpp_path, std.math.maxInt(usize)) catch |err| switch (err) {
5066 error.OutOfMemory => return error.OutOfMemory,5066 error.OutOfMemory => return error.OutOfMemory,
5067 else => |e| {5067 else => |e| {
5068 return comp.failWin32Resource(win32_resource, "failed to read preprocessed file '{s}': {s}", .{ out_rcpp_path, @errorName(e) });5068 return comp.failWin32Resource(win32_resource, "failed to read preprocessed file '{s}': {s}", .{ out_rcpp_path, @errorName(e) });
...@@ -5072,7 +5072,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -5072,7 +5072,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
5072 var mapping_results = try resinator.source_mapping.parseAndRemoveLineCommands(arena, full_input, full_input, .{ .initial_filename = rc_src.src_path });5072 var mapping_results = try resinator.source_mapping.parseAndRemoveLineCommands(arena, full_input, full_input, .{ .initial_filename = rc_src.src_path });
5073 defer mapping_results.mappings.deinit(arena);5073 defer mapping_results.mappings.deinit(arena);
50745074
5075 var final_input = resinator.comments.removeComments(mapping_results.result, mapping_results.result, &mapping_results.mappings);5075 const final_input = resinator.comments.removeComments(mapping_results.result, mapping_results.result, &mapping_results.mappings);
50765076
5077 var output_file = zig_cache_tmp_dir.createFile(out_res_path, .{}) catch |err| {5077 var output_file = zig_cache_tmp_dir.createFile(out_res_path, .{}) catch |err| {
5078 return comp.failWin32Resource(win32_resource, "failed to create output file '{s}': {s}", .{ out_res_path, @errorName(err) });5078 return comp.failWin32Resource(win32_resource, "failed to create output file '{s}': {s}", .{ out_res_path, @errorName(err) });
src/Package/Fetch/git.zig+9-9
...@@ -83,7 +83,7 @@ pub const Repository = struct {...@@ -83,7 +83,7 @@ pub const Repository = struct {
83 ) !void {83 ) !void {
84 try repository.odb.seekOid(commit_oid);84 try repository.odb.seekOid(commit_oid);
85 const tree_oid = tree_oid: {85 const tree_oid = tree_oid: {
86 var commit_object = try repository.odb.readObject();86 const commit_object = try repository.odb.readObject();
87 if (commit_object.type != .commit) return error.NotACommit;87 if (commit_object.type != .commit) return error.NotACommit;
88 break :tree_oid try getCommitTree(commit_object.data);88 break :tree_oid try getCommitTree(commit_object.data);
89 };89 };
...@@ -122,14 +122,14 @@ pub const Repository = struct {...@@ -122,14 +122,14 @@ pub const Repository = struct {
122 var file = try dir.createFile(entry.name, .{});122 var file = try dir.createFile(entry.name, .{});
123 defer file.close();123 defer file.close();
124 try repository.odb.seekOid(entry.oid);124 try repository.odb.seekOid(entry.oid);
125 var file_object = try repository.odb.readObject();125 const file_object = try repository.odb.readObject();
126 if (file_object.type != .blob) return error.InvalidFile;126 if (file_object.type != .blob) return error.InvalidFile;
127 try file.writeAll(file_object.data);127 try file.writeAll(file_object.data);
128 try file.sync();128 try file.sync();
129 },129 },
130 .symlink => {130 .symlink => {
131 try repository.odb.seekOid(entry.oid);131 try repository.odb.seekOid(entry.oid);
132 var symlink_object = try repository.odb.readObject();132 const symlink_object = try repository.odb.readObject();
133 if (symlink_object.type != .blob) return error.InvalidFile;133 if (symlink_object.type != .blob) return error.InvalidFile;
134 const link_name = symlink_object.data;134 const link_name = symlink_object.data;
135 dir.symLink(link_name, entry.name, .{}) catch |e| {135 dir.symLink(link_name, entry.name, .{}) catch |e| {
...@@ -1230,7 +1230,7 @@ fn resolveDeltaChain(...@@ -1230,7 +1230,7 @@ fn resolveDeltaChain(
1230 const delta_offset = delta_offsets[i];1230 const delta_offset = delta_offsets[i];
1231 try pack.seekTo(delta_offset);1231 try pack.seekTo(delta_offset);
1232 const delta_header = try EntryHeader.read(pack.reader());1232 const delta_header = try EntryHeader.read(pack.reader());
1233 var delta_data = try readObjectRaw(allocator, pack.reader(), delta_header.uncompressedLength());1233 const delta_data = try readObjectRaw(allocator, pack.reader(), delta_header.uncompressedLength());
1234 defer allocator.free(delta_data);1234 defer allocator.free(delta_data);
1235 var delta_stream = std.io.fixedBufferStream(delta_data);1235 var delta_stream = std.io.fixedBufferStream(delta_data);
1236 const delta_reader = delta_stream.reader();1236 const delta_reader = delta_stream.reader();
...@@ -1238,7 +1238,7 @@ fn resolveDeltaChain(...@@ -1238,7 +1238,7 @@ fn resolveDeltaChain(
1238 const expanded_size = try readSizeVarInt(delta_reader);1238 const expanded_size = try readSizeVarInt(delta_reader);
12391239
1240 const expanded_alloc_size = std.math.cast(usize, expanded_size) orelse return error.ObjectTooLarge;1240 const expanded_alloc_size = std.math.cast(usize, expanded_size) orelse return error.ObjectTooLarge;
1241 var expanded_data = try allocator.alloc(u8, expanded_alloc_size);1241 const expanded_data = try allocator.alloc(u8, expanded_alloc_size);
1242 errdefer allocator.free(expanded_data);1242 errdefer allocator.free(expanded_data);
1243 var expanded_delta_stream = std.io.fixedBufferStream(expanded_data);1243 var expanded_delta_stream = std.io.fixedBufferStream(expanded_data);
1244 var base_stream = std.io.fixedBufferStream(base_data);1244 var base_stream = std.io.fixedBufferStream(base_data);
...@@ -1259,7 +1259,7 @@ fn readObjectRaw(allocator: Allocator, reader: anytype, size: u64) ![]u8 {...@@ -1259,7 +1259,7 @@ fn readObjectRaw(allocator: Allocator, reader: anytype, size: u64) ![]u8 {
1259 var buffered_reader = std.io.bufferedReader(reader);1259 var buffered_reader = std.io.bufferedReader(reader);
1260 var decompress_stream = try std.compress.zlib.decompressStream(allocator, buffered_reader.reader());1260 var decompress_stream = try std.compress.zlib.decompressStream(allocator, buffered_reader.reader());
1261 defer decompress_stream.deinit();1261 defer decompress_stream.deinit();
1262 var data = try allocator.alloc(u8, alloc_size);1262 const data = try allocator.alloc(u8, alloc_size);
1263 errdefer allocator.free(data);1263 errdefer allocator.free(data);
1264 try decompress_stream.reader().readNoEof(data);1264 try decompress_stream.reader().readNoEof(data);
1265 _ = decompress_stream.reader().readByte() catch |e| switch (e) {1265 _ = decompress_stream.reader().readByte() catch |e| switch (e) {
...@@ -1290,14 +1290,14 @@ fn expandDelta(base_object: anytype, delta_reader: anytype, writer: anytype) !vo...@@ -1290,14 +1290,14 @@ fn expandDelta(base_object: anytype, delta_reader: anytype, writer: anytype) !vo
1290 size2: bool,1290 size2: bool,
1291 size3: bool,1291 size3: bool,
1292 } = @bitCast(inst.value);1292 } = @bitCast(inst.value);
1293 var offset_parts: packed struct { offset1: u8, offset2: u8, offset3: u8, offset4: u8 } = .{1293 const offset_parts: packed struct { offset1: u8, offset2: u8, offset3: u8, offset4: u8 } = .{
1294 .offset1 = if (available.offset1) try delta_reader.readByte() else 0,1294 .offset1 = if (available.offset1) try delta_reader.readByte() else 0,
1295 .offset2 = if (available.offset2) try delta_reader.readByte() else 0,1295 .offset2 = if (available.offset2) try delta_reader.readByte() else 0,
1296 .offset3 = if (available.offset3) try delta_reader.readByte() else 0,1296 .offset3 = if (available.offset3) try delta_reader.readByte() else 0,
1297 .offset4 = if (available.offset4) try delta_reader.readByte() else 0,1297 .offset4 = if (available.offset4) try delta_reader.readByte() else 0,
1298 };1298 };
1299 const offset: u32 = @bitCast(offset_parts);1299 const offset: u32 = @bitCast(offset_parts);
1300 var size_parts: packed struct { size1: u8, size2: u8, size3: u8 } = .{1300 const size_parts: packed struct { size1: u8, size2: u8, size3: u8 } = .{
1301 .size1 = if (available.size1) try delta_reader.readByte() else 0,1301 .size1 = if (available.size1) try delta_reader.readByte() else 0,
1302 .size2 = if (available.size2) try delta_reader.readByte() else 0,1302 .size2 = if (available.size2) try delta_reader.readByte() else 0,
1303 .size3 = if (available.size3) try delta_reader.readByte() else 0,1303 .size3 = if (available.size3) try delta_reader.readByte() else 0,
...@@ -1414,7 +1414,7 @@ test "packfile indexing and checkout" {...@@ -1414,7 +1414,7 @@ test "packfile indexing and checkout" {
1414 defer walker.deinit();1414 defer walker.deinit();
1415 while (try walker.next()) |entry| {1415 while (try walker.next()) |entry| {
1416 if (entry.kind != .file) continue;1416 if (entry.kind != .file) continue;
1417 var path = try testing.allocator.dupe(u8, entry.path);1417 const path = try testing.allocator.dupe(u8, entry.path);
1418 errdefer testing.allocator.free(path);1418 errdefer testing.allocator.free(path);
1419 mem.replaceScalar(u8, path, std.fs.path.sep, '/');1419 mem.replaceScalar(u8, path, std.fs.path.sep, '/');
1420 try actual_files.append(testing.allocator, path);1420 try actual_files.append(testing.allocator, path);
src/Sema.zig+9-9
...@@ -22899,7 +22899,7 @@ fn checkSimdBinOp(...@@ -22899,7 +22899,7 @@ fn checkSimdBinOp(
22899 const rhs_ty = sema.typeOf(uncasted_rhs);22899 const rhs_ty = sema.typeOf(uncasted_rhs);
2290022900
22901 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);22901 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
22902 var vec_len: ?usize = if (lhs_ty.zigTypeTag(mod) == .Vector) lhs_ty.vectorLen(mod) else null;22902 const vec_len: ?usize = if (lhs_ty.zigTypeTag(mod) == .Vector) lhs_ty.vectorLen(mod) else null;
22903 const result_ty = try sema.resolvePeerTypes(block, src, &.{ uncasted_lhs, uncasted_rhs }, .{22903 const result_ty = try sema.resolvePeerTypes(block, src, &.{ uncasted_lhs, uncasted_rhs }, .{
22904 .override = &[_]?LazySrcLoc{ lhs_src, rhs_src },22904 .override = &[_]?LazySrcLoc{ lhs_src, rhs_src },
22905 });22905 });
...@@ -23286,8 +23286,8 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -23286,8 +23286,8 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
2328623286
23287 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);23287 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
23288 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);23288 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);
23289 var a = try sema.resolveInst(extra.a);23289 const a = try sema.resolveInst(extra.a);
23290 var b = try sema.resolveInst(extra.b);23290 const b = try sema.resolveInst(extra.b);
23291 var mask = try sema.resolveInst(extra.mask);23291 var mask = try sema.resolveInst(extra.mask);
23292 var mask_ty = sema.typeOf(mask);23292 var mask_ty = sema.typeOf(mask);
2329323293
...@@ -23328,7 +23328,7 @@ fn analyzeShuffle(...@@ -23328,7 +23328,7 @@ fn analyzeShuffle(
23328 .child = elem_ty.toIntern(),23328 .child = elem_ty.toIntern(),
23329 });23329 });
2333023330
23331 var maybe_a_len = switch (sema.typeOf(a).zigTypeTag(mod)) {23331 const maybe_a_len = switch (sema.typeOf(a).zigTypeTag(mod)) {
23332 .Array, .Vector => sema.typeOf(a).arrayLen(mod),23332 .Array, .Vector => sema.typeOf(a).arrayLen(mod),
23333 .Undefined => null,23333 .Undefined => null,
23334 else => return sema.fail(block, a_src, "expected vector or array with element type '{}', found '{}'", .{23334 else => return sema.fail(block, a_src, "expected vector or array with element type '{}', found '{}'", .{
...@@ -23336,7 +23336,7 @@ fn analyzeShuffle(...@@ -23336,7 +23336,7 @@ fn analyzeShuffle(
23336 sema.typeOf(a).fmt(sema.mod),23336 sema.typeOf(a).fmt(sema.mod),
23337 }),23337 }),
23338 };23338 };
23339 var maybe_b_len = switch (sema.typeOf(b).zigTypeTag(mod)) {23339 const maybe_b_len = switch (sema.typeOf(b).zigTypeTag(mod)) {
23340 .Array, .Vector => sema.typeOf(b).arrayLen(mod),23340 .Array, .Vector => sema.typeOf(b).arrayLen(mod),
23341 .Undefined => null,23341 .Undefined => null,
23342 else => return sema.fail(block, b_src, "expected vector or array with element type '{}', found '{}'", .{23342 else => return sema.fail(block, b_src, "expected vector or array with element type '{}', found '{}'", .{
...@@ -23801,7 +23801,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -23801,7 +23801,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
23801 const call_src = inst_data.src();23801 const call_src = inst_data.src();
2380223802
23803 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;23803 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;
23804 var func = try sema.resolveInst(extra.callee);23804 const func = try sema.resolveInst(extra.callee);
2380523805
23806 const modifier_ty = try sema.getBuiltinType("CallModifier");23806 const modifier_ty = try sema.getBuiltinType("CallModifier");
23807 const air_ref = try sema.resolveInst(extra.modifier);23807 const air_ref = try sema.resolveInst(extra.modifier);
...@@ -23859,7 +23859,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -23859,7 +23859,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
23859 return sema.fail(block, args_src, "expected a tuple, found '{}'", .{args_ty.fmt(sema.mod)});23859 return sema.fail(block, args_src, "expected a tuple, found '{}'", .{args_ty.fmt(sema.mod)});
23860 }23860 }
2386123861
23862 var resolved_args: []Air.Inst.Ref = try sema.arena.alloc(Air.Inst.Ref, args_ty.structFieldCount(mod));23862 const resolved_args: []Air.Inst.Ref = try sema.arena.alloc(Air.Inst.Ref, args_ty.structFieldCount(mod));
23863 for (resolved_args, 0..) |*resolved, i| {23863 for (resolved_args, 0..) |*resolved, i| {
23864 resolved.* = try sema.tupleFieldValByIndex(block, args_src, args, @intCast(i), args_ty);23864 resolved.* = try sema.tupleFieldValByIndex(block, args_src, args, @intCast(i), args_ty);
23865 }23865 }
...@@ -33274,8 +33274,8 @@ fn resolvePeerTypes(...@@ -33274,8 +33274,8 @@ fn resolvePeerTypes(
33274 else => {},33274 else => {},
33275 }33275 }
3327633276
33277 var peer_tys = try sema.arena.alloc(?Type, instructions.len);33277 const peer_tys = try sema.arena.alloc(?Type, instructions.len);
33278 var peer_vals = try sema.arena.alloc(?Value, instructions.len);33278 const peer_vals = try sema.arena.alloc(?Value, instructions.len);
3327933279
33280 for (instructions, peer_tys, peer_vals) |inst, *ty, *val| {33280 for (instructions, peer_tys, peer_vals) |inst, *ty, *val| {
33281 ty.* = sema.typeOf(inst);33281 ty.* = sema.typeOf(inst);
src/arch/riscv64/CodeGen.zig+5
...@@ -2648,6 +2648,11 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {...@@ -2648,6 +2648,11 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
2648 // conventions2648 // conventions
2649 var next_register: usize = 0;2649 var next_register: usize = 0;
2650 var next_stack_offset: u32 = 0;2650 var next_stack_offset: u32 = 0;
2651 // TODO: this is never assigned, which is a bug, but I don't know how this code works
2652 // well enough to try and fix it. I *think* `next_register += next_stack_offset` is
2653 // supposed to be `next_stack_offset += param_size` in every case where it appears.
2654 _ = &next_stack_offset;
2655
2651 const argument_registers = [_]Register{ .a0, .a1, .a2, .a3, .a4, .a5, .a6, .a7 };2656 const argument_registers = [_]Register{ .a0, .a1, .a2, .a3, .a4, .a5, .a6, .a7 };
26522657
2653 for (fn_info.param_types.get(ip), result.args) |ty, *result_arg| {2658 for (fn_info.param_types.get(ip), result.args) |ty, *result_arg| {
src/arch/sparc64/CodeGen.zig+4
...@@ -4481,6 +4481,10 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView)...@@ -4481,6 +4481,10 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView)
44814481
4482 var next_register: usize = 0;4482 var next_register: usize = 0;
4483 var next_stack_offset: u32 = 0;4483 var next_stack_offset: u32 = 0;
4484 // TODO: this is never assigned, which is a bug, but I don't know how this code works
4485 // well enough to try and fix it. I *think* `next_register += next_stack_offset` is
4486 // supposed to be `next_stack_offset += param_size` in every case where it appears.
4487 _ = &next_stack_offset;
44844488
4485 // The caller puts the argument in %o0-%o5, which becomes %i0-%i5 inside the callee.4489 // The caller puts the argument in %o0-%o5, which becomes %i0-%i5 inside the callee.
4486 const argument_registers = switch (role) {4490 const argument_registers = switch (role) {
src/arch/wasm/CodeGen.zig+4-4
...@@ -2139,7 +2139,7 @@ fn airRetPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2139,7 +2139,7 @@ fn airRetPtr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2139 const mod = func.bin_file.base.options.module.?;2139 const mod = func.bin_file.base.options.module.?;
2140 const child_type = func.typeOfIndex(inst).childType(mod);2140 const child_type = func.typeOfIndex(inst).childType(mod);
21412141
2142 var result = result: {2142 const result = result: {
2143 if (!child_type.isFnOrHasRuntimeBitsIgnoreComptime(mod)) {2143 if (!child_type.isFnOrHasRuntimeBitsIgnoreComptime(mod)) {
2144 break :result try func.allocStack(Type.usize); // create pointer to void2144 break :result try func.allocStack(Type.usize); // create pointer to void
2145 }2145 }
...@@ -5001,7 +5001,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5001,7 +5001,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5001 return func.finishAir(inst, try WValue.toLocal(.stack, func, elem_ty), &.{ bin_op.lhs, bin_op.rhs });5001 return func.finishAir(inst, try WValue.toLocal(.stack, func, elem_ty), &.{ bin_op.lhs, bin_op.rhs });
5002 },5002 },
5003 else => {5003 else => {
5004 var stack_vec = try func.allocStack(array_ty);5004 const stack_vec = try func.allocStack(array_ty);
5005 try func.store(stack_vec, array, array_ty, 0);5005 try func.store(stack_vec, array, array_ty, 0);
50065006
5007 // Is a non-unrolled vector (v128)5007 // Is a non-unrolled vector (v128)
...@@ -5944,7 +5944,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro...@@ -5944,7 +5944,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro
5944 rhs.free(func);5944 rhs.free(func);
5945 };5945 };
59465946
5947 var bin_op = try (try func.binOp(lhs, rhs, lhs_ty, op)).toLocal(func, lhs_ty);5947 const bin_op = try (try func.binOp(lhs, rhs, lhs_ty, op)).toLocal(func, lhs_ty);
5948 var result = if (wasm_bits != int_info.bits) blk: {5948 var result = if (wasm_bits != int_info.bits) blk: {
5949 break :blk try (try func.wrapOperand(bin_op, lhs_ty)).toLocal(func, lhs_ty);5949 break :blk try (try func.wrapOperand(bin_op, lhs_ty)).toLocal(func, lhs_ty);
5950 } else bin_op;5950 } else bin_op;
...@@ -6335,7 +6335,7 @@ fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6335,7 +6335,7 @@ fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6335 const lhs_ext = try func.fpext(lhs, ty, Type.f32);6335 const lhs_ext = try func.fpext(lhs, ty, Type.f32);
6336 const addend_ext = try func.fpext(addend, ty, Type.f32);6336 const addend_ext = try func.fpext(addend, ty, Type.f32);
6337 // call to compiler-rt `fn fmaf(f32, f32, f32) f32`6337 // call to compiler-rt `fn fmaf(f32, f32, f32) f32`
6338 var result = try func.callIntrinsic(6338 const result = try func.callIntrinsic(
6339 "fmaf",6339 "fmaf",
6340 &.{ .f32_type, .f32_type, .f32_type },6340 &.{ .f32_type, .f32_type, .f32_type },
6341 Type.f32,6341 Type.f32,
src/arch/x86_64/CodeGen.zig+1-1
...@@ -2181,7 +2181,7 @@ fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void {...@@ -2181,7 +2181,7 @@ fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void {
2181 const ret_reg = param_regs[0];2181 const ret_reg = param_regs[0];
2182 const enum_mcv = MCValue{ .register = param_regs[1] };2182 const enum_mcv = MCValue{ .register = param_regs[1] };
21832183
2184 var exitlude_jump_relocs = try self.gpa.alloc(Mir.Inst.Index, enum_ty.enumFieldCount(mod));2184 const exitlude_jump_relocs = try self.gpa.alloc(Mir.Inst.Index, enum_ty.enumFieldCount(mod));
2185 defer self.gpa.free(exitlude_jump_relocs);2185 defer self.gpa.free(exitlude_jump_relocs);
21862186
2187 const data_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);2187 const data_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);
src/arch/x86_64/Disassembler.zig+1-2
...@@ -234,13 +234,12 @@ fn inst(encoding: Encoding, args: struct {...@@ -234,13 +234,12 @@ fn inst(encoding: Encoding, args: struct {
234 op3: Instruction.Operand = .none,234 op3: Instruction.Operand = .none,
235 op4: Instruction.Operand = .none,235 op4: Instruction.Operand = .none,
236}) Instruction {236}) Instruction {
237 var i = Instruction{ .encoding = encoding, .prefix = args.prefix, .ops = .{237 return .{ .encoding = encoding, .prefix = args.prefix, .ops = .{
238 args.op1,238 args.op1,
239 args.op2,239 args.op2,
240 args.op3,240 args.op3,
241 args.op4,241 args.op4,
242 } };242 } };
243 return i;
244}243}
245244
246const Prefixes = struct {245const Prefixes = struct {
src/arch/x86_64/Lower.zig+1-1
...@@ -342,7 +342,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)...@@ -342,7 +342,7 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
342 .Lib => lower.bin_file.options.link_mode == .Static,342 .Lib => lower.bin_file.options.link_mode == .Static,
343 };343 };
344344
345 var emit_prefix = prefix;345 const emit_prefix = prefix;
346 var emit_mnemonic = mnemonic;346 var emit_mnemonic = mnemonic;
347 var emit_ops_storage: [4]Operand = undefined;347 var emit_ops_storage: [4]Operand = undefined;
348 const emit_ops = emit_ops_storage[0..ops.len];348 const emit_ops = emit_ops_storage[0..ops.len];
src/arch/x86_64/encoder.zig+2-2
...@@ -244,7 +244,7 @@ pub const Instruction = struct {...@@ -244,7 +244,7 @@ pub const Instruction = struct {
244 }),244 }),
245 },245 },
246 .imm => |imm| if (enc_op.isSigned()) {246 .imm => |imm| if (enc_op.isSigned()) {
247 var imms = imm.asSigned(enc_op.immBitSize());247 const imms = imm.asSigned(enc_op.immBitSize());
248 if (imms < 0) try writer.writeByte('-');248 if (imms < 0) try writer.writeByte('-');
249 try writer.print("0x{x}", .{@abs(imms)});249 try writer.print("0x{x}", .{@abs(imms)});
250 } else try writer.print("0x{x}", .{imm.asUnsigned(enc_op.immBitSize())}),250 } else try writer.print("0x{x}", .{imm.asUnsigned(enc_op.immBitSize())}),
...@@ -1077,7 +1077,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8, assembly: []co...@@ -1077,7 +1077,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8, assembly: []co
1077 const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{std.fmt.fmtSliceHexLower(given)});1077 const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{std.fmt.fmtSliceHexLower(given)});
1078 defer testing.allocator.free(given_fmt);1078 defer testing.allocator.free(given_fmt);
1079 const idx = std.mem.indexOfDiff(u8, expected_fmt, given_fmt).?;1079 const idx = std.mem.indexOfDiff(u8, expected_fmt, given_fmt).?;
1080 var padding = try testing.allocator.alloc(u8, idx + 5);1080 const padding = try testing.allocator.alloc(u8, idx + 5);
1081 defer testing.allocator.free(padding);1081 defer testing.allocator.free(padding);
1082 @memset(padding, ' ');1082 @memset(padding, ' ');
1083 std.debug.print("\nASM: {s}\nEXP: {s}\nGIV: {s}\n{s}^ -- first differing byte\n", .{1083 std.debug.print("\nASM: {s}\nEXP: {s}\nGIV: {s}\n{s}^ -- first differing byte\n", .{
src/aro_translate_c.zig+2-2
...@@ -346,7 +346,7 @@ fn transFnDecl(c: *Context, fn_decl: NodeIndex) Error!void {...@@ -346,7 +346,7 @@ fn transFnDecl(c: *Context, fn_decl: NodeIndex) Error!void {
346 defer block_scope.deinit();346 defer block_scope.deinit();
347347
348 var scope = &block_scope.base;348 var scope = &block_scope.base;
349 _ = scope;349 _ = &scope;
350350
351 var param_id: c_uint = 0;351 var param_id: c_uint = 0;
352 for (proto_payload.data.params, fn_ty.data.func.params) |*param, param_info| {352 for (proto_payload.data.params, fn_ty.data.func.params) |*param, param_info| {
...@@ -534,7 +534,7 @@ fn transFnType(...@@ -534,7 +534,7 @@ fn transFnType(
534 ctx: FnProtoContext,534 ctx: FnProtoContext,
535) !ZigNode {535) !ZigNode {
536 const param_count: usize = fn_ty.data.func.params.len;536 const param_count: usize = fn_ty.data.func.params.len;
537 var fn_params = try c.arena.alloc(ast.Payload.Param, param_count);537 const fn_params = try c.arena.alloc(ast.Payload.Param, param_count);
538538
539 for (fn_ty.data.func.params, fn_params) |param_info, *param_node| {539 for (fn_ty.data.func.params, fn_params) |param_info, *param_node| {
540 const param_ty = param_info.ty;540 const param_ty = param_info.ty;
src/codegen.zig+1-1
...@@ -368,7 +368,7 @@ pub fn generateSymbol(...@@ -368,7 +368,7 @@ pub fn generateSymbol(
368 .bytes => |bytes| try code.appendSlice(bytes),368 .bytes => |bytes| try code.appendSlice(bytes),
369 .elems, .repeated_elem => {369 .elems, .repeated_elem => {
370 var index: u64 = 0;370 var index: u64 = 0;
371 var len_including_sentinel =371 const len_including_sentinel =
372 array_type.len + @intFromBool(array_type.sentinel != .none);372 array_type.len + @intFromBool(array_type.sentinel != .none);
373 while (index < len_including_sentinel) : (index += 1) {373 while (index < len_including_sentinel) : (index += 1) {
374 switch (try generateSymbol(bin_file, src_loc, .{374 switch (try generateSymbol(bin_file, src_loc, .{
src/codegen/llvm/BitcodeReader.zig+1-1
...@@ -410,7 +410,7 @@ fn readVbr(bc: *BitcodeReader, comptime T: type, bits: u7) !T {...@@ -410,7 +410,7 @@ fn readVbr(bc: *BitcodeReader, comptime T: type, bits: u7) !T {
410 var result: u64 = 0;410 var result: u64 = 0;
411 var shift: u6 = 0;411 var shift: u6 = 0;
412 while (true) {412 while (true) {
413 var chunk = try bc.readFixed(u64, bits);413 const chunk = try bc.readFixed(u64, bits);
414 result |= (chunk & (chunk_msb - 1)) << shift;414 result |= (chunk & (chunk_msb - 1)) << shift;
415 if (chunk & chunk_msb == 0) break;415 if (chunk & chunk_msb == 0) break;
416 shift += chunk_bits;416 shift += chunk_bits;
src/codegen/spirv.zig+4-4
...@@ -1284,7 +1284,7 @@ const DeclGen = struct {...@@ -1284,7 +1284,7 @@ const DeclGen = struct {
12841284
1285 const elem_ty = ty.childType(mod);1285 const elem_ty = ty.childType(mod);
1286 const elem_ty_ref = try self.resolveType(elem_ty, .indirect);1286 const elem_ty_ref = try self.resolveType(elem_ty, .indirect);
1287 var total_len = std.math.cast(u32, ty.arrayLenIncludingSentinel(mod)) orelse {1287 const total_len = std.math.cast(u32, ty.arrayLenIncludingSentinel(mod)) orelse {
1288 return self.fail("array type of {} elements is too large", .{ty.arrayLenIncludingSentinel(mod)});1288 return self.fail("array type of {} elements is too large", .{ty.arrayLenIncludingSentinel(mod)});
1289 };1289 };
1290 const ty_ref = if (!elem_ty.hasRuntimeBitsIgnoreComptime(mod)) blk: {1290 const ty_ref = if (!elem_ty.hasRuntimeBitsIgnoreComptime(mod)) blk: {
...@@ -2115,7 +2115,7 @@ const DeclGen = struct {...@@ -2115,7 +2115,7 @@ const DeclGen = struct {
2115 const child_ty = ty.childType(mod);2115 const child_ty = ty.childType(mod);
2116 const vector_len = ty.vectorLen(mod);2116 const vector_len = ty.vectorLen(mod);
21172117
2118 var constituents = try self.gpa.alloc(IdRef, vector_len);2118 const constituents = try self.gpa.alloc(IdRef, vector_len);
2119 defer self.gpa.free(constituents);2119 defer self.gpa.free(constituents);
21202120
2121 for (constituents, 0..) |*constituent, i| {2121 for (constituents, 0..) |*constituent, i| {
...@@ -2312,7 +2312,7 @@ const DeclGen = struct {...@@ -2312,7 +2312,7 @@ const DeclGen = struct {
2312 if (ty.isVector(mod)) {2312 if (ty.isVector(mod)) {
2313 const child_ty = ty.childType(mod);2313 const child_ty = ty.childType(mod);
2314 const vector_len = ty.vectorLen(mod);2314 const vector_len = ty.vectorLen(mod);
2315 var constituents = try self.gpa.alloc(IdRef, vector_len);2315 const constituents = try self.gpa.alloc(IdRef, vector_len);
2316 defer self.gpa.free(constituents);2316 defer self.gpa.free(constituents);
23172317
2318 for (constituents, 0..) |*constituent, i| {2318 for (constituents, 0..) |*constituent, i| {
...@@ -2727,7 +2727,7 @@ const DeclGen = struct {...@@ -2727,7 +2727,7 @@ const DeclGen = struct {
2727 const child_ty = ty.childType(mod);2727 const child_ty = ty.childType(mod);
2728 const vector_len = ty.vectorLen(mod);2728 const vector_len = ty.vectorLen(mod);
27292729
2730 var constituents = try self.gpa.alloc(IdRef, vector_len);2730 const constituents = try self.gpa.alloc(IdRef, vector_len);
2731 defer self.gpa.free(constituents);2731 defer self.gpa.free(constituents);
27322732
2733 for (constituents, 0..) |*constituent, i| {2733 for (constituents, 0..) |*constituent, i| {
src/link/C.zig+1-1
...@@ -103,7 +103,7 @@ pub fn openPath(gpa: Allocator, sub_path: []const u8, options: link.Options) !*C...@@ -103,7 +103,7 @@ pub fn openPath(gpa: Allocator, sub_path: []const u8, options: link.Options) !*C
103 });103 });
104 errdefer file.close();104 errdefer file.close();
105105
106 var c_file = try gpa.create(C);106 const c_file = try gpa.create(C);
107 errdefer gpa.destroy(c_file);107 errdefer gpa.destroy(c_file);
108108
109 c_file.* = .{109 c_file.* = .{
src/link/Coff.zig+5-5
...@@ -563,7 +563,7 @@ fn allocateAtom(self: *Coff, atom_index: Atom.Index, new_atom_size: u32, alignme...@@ -563,7 +563,7 @@ fn allocateAtom(self: *Coff, atom_index: Atom.Index, new_atom_size: u32, alignme
563563
564 // First we look for an appropriately sized free list node.564 // First we look for an appropriately sized free list node.
565 // The list is unordered. We'll just take the first thing that works.565 // The list is unordered. We'll just take the first thing that works.
566 var vaddr = blk: {566 const vaddr = blk: {
567 var i: usize = 0;567 var i: usize = 0;
568 while (i < free_list.items.len) {568 while (i < free_list.items.len) {
569 const big_atom_index = free_list.items[i];569 const big_atom_index = free_list.items[i];
...@@ -815,7 +815,7 @@ fn writeAtom(self: *Coff, atom_index: Atom.Index, code: []u8) !void {...@@ -815,7 +815,7 @@ fn writeAtom(self: *Coff, atom_index: Atom.Index, code: []u8) !void {
815}815}
816816
817fn debugMem(allocator: Allocator, handle: std.ChildProcess.Id, pvaddr: std.os.windows.LPVOID, code: []const u8) !void {817fn debugMem(allocator: Allocator, handle: std.ChildProcess.Id, pvaddr: std.os.windows.LPVOID, code: []const u8) !void {
818 var buffer = try allocator.alloc(u8, code.len);818 const buffer = try allocator.alloc(u8, code.len);
819 defer allocator.free(buffer);819 defer allocator.free(buffer);
820 const memread = try std.os.windows.ReadProcessMemory(handle, pvaddr, buffer);820 const memread = try std.os.windows.ReadProcessMemory(handle, pvaddr, buffer);
821 log.debug("to write: {x}", .{std.fmt.fmtSliceHexLower(code)});821 log.debug("to write: {x}", .{std.fmt.fmtSliceHexLower(code)});
...@@ -1071,7 +1071,7 @@ pub fn updateFunc(self: *Coff, mod: *Module, func_index: InternPool.Index, air:...@@ -1071,7 +1071,7 @@ pub fn updateFunc(self: *Coff, mod: *Module, func_index: InternPool.Index, air:
1071 &code_buffer,1071 &code_buffer,
1072 .none,1072 .none,
1073 );1073 );
1074 var code = switch (res) {1074 const code = switch (res) {
1075 .ok => code_buffer.items,1075 .ok => code_buffer.items,
1076 .fail => |em| {1076 .fail => |em| {
1077 decl.analysis = .codegen_failure;1077 decl.analysis = .codegen_failure;
...@@ -1132,7 +1132,7 @@ fn lowerConst(self: *Coff, name: []const u8, tv: TypedValue, required_alignment:...@@ -1132,7 +1132,7 @@ fn lowerConst(self: *Coff, name: []const u8, tv: TypedValue, required_alignment:
1132 const res = try codegen.generateSymbol(&self.base, src_loc, tv, &code_buffer, .none, .{1132 const res = try codegen.generateSymbol(&self.base, src_loc, tv, &code_buffer, .none, .{
1133 .parent_atom_index = self.getAtom(atom_index).getSymbolIndex().?,1133 .parent_atom_index = self.getAtom(atom_index).getSymbolIndex().?,
1134 });1134 });
1135 var code = switch (res) {1135 const code = switch (res) {
1136 .ok => code_buffer.items,1136 .ok => code_buffer.items,
1137 .fail => |em| return .{ .fail = em },1137 .fail => |em| return .{ .fail = em },
1138 };1138 };
...@@ -1196,7 +1196,7 @@ pub fn updateDecl(...@@ -1196,7 +1196,7 @@ pub fn updateDecl(
1196 }, &code_buffer, .none, .{1196 }, &code_buffer, .none, .{
1197 .parent_atom_index = atom.getSymbolIndex().?,1197 .parent_atom_index = atom.getSymbolIndex().?,
1198 });1198 });
1199 var code = switch (res) {1199 const code = switch (res) {
1200 .ok => code_buffer.items,1200 .ok => code_buffer.items,
1201 .fail => |em| {1201 .fail => |em| {
1202 decl.analysis = .codegen_failure;1202 decl.analysis = .codegen_failure;
src/link/Dwarf.zig+3-3
...@@ -303,7 +303,7 @@ pub const DeclState = struct {...@@ -303,7 +303,7 @@ pub const DeclState = struct {
303 // DW.AT.name, DW.FORM.string303 // DW.AT.name, DW.FORM.string
304 try dbg_info_buffer.writer().print("{d}\x00", .{field_index});304 try dbg_info_buffer.writer().print("{d}\x00", .{field_index});
305 // DW.AT.type, DW.FORM.ref4305 // DW.AT.type, DW.FORM.ref4
306 var index = dbg_info_buffer.items.len;306 const index = dbg_info_buffer.items.len;
307 try dbg_info_buffer.resize(index + 4);307 try dbg_info_buffer.resize(index + 4);
308 try self.addTypeRelocGlobal(atom_index, field_ty.toType(), @intCast(index));308 try self.addTypeRelocGlobal(atom_index, field_ty.toType(), @intCast(index));
309 // DW.AT.data_member_location, DW.FORM.udata309 // DW.AT.data_member_location, DW.FORM.udata
...@@ -329,7 +329,7 @@ pub const DeclState = struct {...@@ -329,7 +329,7 @@ pub const DeclState = struct {
329 // DW.AT.name, DW.FORM.string329 // DW.AT.name, DW.FORM.string
330 try dbg_info_buffer.writer().print("{d}\x00", .{field_index});330 try dbg_info_buffer.writer().print("{d}\x00", .{field_index});
331 // DW.AT.type, DW.FORM.ref4331 // DW.AT.type, DW.FORM.ref4
332 var index = dbg_info_buffer.items.len;332 const index = dbg_info_buffer.items.len;
333 try dbg_info_buffer.resize(index + 4);333 try dbg_info_buffer.resize(index + 4);
334 try self.addTypeRelocGlobal(atom_index, field_ty.toType(), @intCast(index));334 try self.addTypeRelocGlobal(atom_index, field_ty.toType(), @intCast(index));
335 // DW.AT.data_member_location, DW.FORM.udata335 // DW.AT.data_member_location, DW.FORM.udata
...@@ -350,7 +350,7 @@ pub const DeclState = struct {...@@ -350,7 +350,7 @@ pub const DeclState = struct {
350 dbg_info_buffer.appendSliceAssumeCapacity(field_name);350 dbg_info_buffer.appendSliceAssumeCapacity(field_name);
351 dbg_info_buffer.appendAssumeCapacity(0);351 dbg_info_buffer.appendAssumeCapacity(0);
352 // DW.AT.type, DW.FORM.ref4352 // DW.AT.type, DW.FORM.ref4
353 var index = dbg_info_buffer.items.len;353 const index = dbg_info_buffer.items.len;
354 try dbg_info_buffer.resize(index + 4);354 try dbg_info_buffer.resize(index + 4);
355 try self.addTypeRelocGlobal(atom_index, field_ty.toType(), @intCast(index));355 try self.addTypeRelocGlobal(atom_index, field_ty.toType(), @intCast(index));
356 // DW.AT.data_member_location, DW.FORM.udata356 // DW.AT.data_member_location, DW.FORM.udata
src/link/Elf.zig+5-5
...@@ -967,7 +967,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node...@@ -967,7 +967,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
967 // --verbose-link967 // --verbose-link
968 if (self.base.options.verbose_link) try self.dumpArgv(comp);968 if (self.base.options.verbose_link) try self.dumpArgv(comp);
969969
970 var csu = try CsuObjects.init(arena, self.base.options, comp);970 const csu = try CsuObjects.init(arena, self.base.options, comp);
971 const compiler_rt_path: ?[]const u8 = blk: {971 const compiler_rt_path: ?[]const u8 = blk: {
972 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;972 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;
973 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;973 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;
...@@ -1493,7 +1493,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {...@@ -1493,7 +1493,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {
1493 } else null;1493 } else null;
1494 const gc_sections = self.base.options.gc_sections orelse false;1494 const gc_sections = self.base.options.gc_sections orelse false;
14951495
1496 var csu = try CsuObjects.init(arena, self.base.options, comp);1496 const csu = try CsuObjects.init(arena, self.base.options, comp);
1497 const compiler_rt_path: ?[]const u8 = blk: {1497 const compiler_rt_path: ?[]const u8 = blk: {
1498 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;1498 if (comp.compiler_rt_lib) |x| break :blk x.full_object_path;
1499 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;1499 if (comp.compiler_rt_obj) |x| break :blk x.full_object_path;
...@@ -2599,7 +2599,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v...@@ -2599,7 +2599,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
2599 try argv.append(full_out_path);2599 try argv.append(full_out_path);
26002600
2601 // csu prelude2601 // csu prelude
2602 var csu = try CsuObjects.init(arena, self.base.options, comp);2602 const csu = try CsuObjects.init(arena, self.base.options, comp);
2603 if (csu.crt0) |v| try argv.append(v);2603 if (csu.crt0) |v| try argv.append(v);
2604 if (csu.crti) |v| try argv.append(v);2604 if (csu.crti) |v| try argv.append(v);
2605 if (csu.crtbegin) |v| try argv.append(v);2605 if (csu.crtbegin) |v| try argv.append(v);
...@@ -3852,7 +3852,7 @@ fn sortPhdrs(self: *Elf) error{OutOfMemory}!void {...@@ -3852,7 +3852,7 @@ fn sortPhdrs(self: *Elf) error{OutOfMemory}!void {
3852 backlinks[entry.phndx] = @as(u16, @intCast(i));3852 backlinks[entry.phndx] = @as(u16, @intCast(i));
3853 }3853 }
38543854
3855 var slice = try self.phdrs.toOwnedSlice(gpa);3855 const slice = try self.phdrs.toOwnedSlice(gpa);
3856 defer gpa.free(slice);3856 defer gpa.free(slice);
38573857
3858 try self.phdrs.ensureTotalCapacityPrecise(gpa, slice.len);3858 try self.phdrs.ensureTotalCapacityPrecise(gpa, slice.len);
...@@ -3957,7 +3957,7 @@ fn sortShdrs(self: *Elf) !void {...@@ -3957,7 +3957,7 @@ fn sortShdrs(self: *Elf) !void {
3957 backlinks[entry.shndx] = @as(u16, @intCast(i));3957 backlinks[entry.shndx] = @as(u16, @intCast(i));
3958 }3958 }
39593959
3960 var slice = try self.shdrs.toOwnedSlice(gpa);3960 const slice = try self.shdrs.toOwnedSlice(gpa);
3961 defer gpa.free(slice);3961 defer gpa.free(slice);
39623962
3963 try self.shdrs.ensureTotalCapacityPrecise(gpa, slice.len);3963 try self.shdrs.ensureTotalCapacityPrecise(gpa, slice.len);
src/link/Elf/eh_frame.zig+1-1
...@@ -217,7 +217,7 @@ pub const Iterator = struct {...@@ -217,7 +217,7 @@ pub const Iterator = struct {
217 var stream = std.io.fixedBufferStream(it.data[it.pos..]);217 var stream = std.io.fixedBufferStream(it.data[it.pos..]);
218 const reader = stream.reader();218 const reader = stream.reader();
219219
220 var size = try reader.readInt(u32, .little);220 const size = try reader.readInt(u32, .little);
221 if (size == 0xFFFFFFFF) @panic("TODO");221 if (size == 0xFFFFFFFF) @panic("TODO");
222222
223 const id = try reader.readInt(u32, .little);223 const id = try reader.readInt(u32, .little);
src/link/MachO.zig+7-7
...@@ -2252,7 +2252,7 @@ pub fn updateFunc(self: *MachO, mod: *Module, func_index: InternPool.Index, air:...@@ -2252,7 +2252,7 @@ pub fn updateFunc(self: *MachO, mod: *Module, func_index: InternPool.Index, air:
2252 else2252 else
2253 try codegen.generateFunction(&self.base, decl.srcLoc(mod), func_index, air, liveness, &code_buffer, .none);2253 try codegen.generateFunction(&self.base, decl.srcLoc(mod), func_index, air, liveness, &code_buffer, .none);
22542254
2255 var code = switch (res) {2255 const code = switch (res) {
2256 .ok => code_buffer.items,2256 .ok => code_buffer.items,
2257 .fail => |em| {2257 .fail => |em| {
2258 decl.analysis = .codegen_failure;2258 decl.analysis = .codegen_failure;
...@@ -2332,7 +2332,7 @@ fn lowerConst(...@@ -2332,7 +2332,7 @@ fn lowerConst(
2332 const res = try codegen.generateSymbol(&self.base, src_loc, tv, &code_buffer, .none, .{2332 const res = try codegen.generateSymbol(&self.base, src_loc, tv, &code_buffer, .none, .{
2333 .parent_atom_index = self.getAtom(atom_index).getSymbolIndex().?,2333 .parent_atom_index = self.getAtom(atom_index).getSymbolIndex().?,
2334 });2334 });
2335 var code = switch (res) {2335 const code = switch (res) {
2336 .ok => code_buffer.items,2336 .ok => code_buffer.items,
2337 .fail => |em| return .{ .fail = em },2337 .fail => |em| return .{ .fail = em },
2338 };2338 };
...@@ -2418,7 +2418,7 @@ pub fn updateDecl(self: *MachO, mod: *Module, decl_index: Module.Decl.Index) !vo...@@ -2418,7 +2418,7 @@ pub fn updateDecl(self: *MachO, mod: *Module, decl_index: Module.Decl.Index) !vo
2418 .parent_atom_index = sym_index,2418 .parent_atom_index = sym_index,
2419 });2419 });
24202420
2421 var code = switch (res) {2421 const code = switch (res) {
2422 .ok => code_buffer.items,2422 .ok => code_buffer.items,
2423 .fail => |em| {2423 .fail => |em| {
2424 decl.analysis = .codegen_failure;2424 decl.analysis = .codegen_failure;
...@@ -2587,7 +2587,7 @@ fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: Module.D...@@ -2587,7 +2587,7 @@ fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: Module.D
2587 .parent_atom_index = init_sym_index,2587 .parent_atom_index = init_sym_index,
2588 });2588 });
25892589
2590 var code = switch (res) {2590 const code = switch (res) {
2591 .ok => code_buffer.items,2591 .ok => code_buffer.items,
2592 .fail => |em| {2592 .fail => |em| {
2593 decl.analysis = .codegen_failure;2593 decl.analysis = .codegen_failure;
...@@ -3427,7 +3427,7 @@ fn allocateAtom(self: *MachO, atom_index: Atom.Index, new_atom_size: u64, alignm...@@ -3427,7 +3427,7 @@ fn allocateAtom(self: *MachO, atom_index: Atom.Index, new_atom_size: u64, alignm
34273427
3428 // First we look for an appropriately sized free list node.3428 // First we look for an appropriately sized free list node.
3429 // The list is unordered. We'll just take the first thing that works.3429 // The list is unordered. We'll just take the first thing that works.
3430 var vaddr = blk: {3430 const vaddr = blk: {
3431 var i: usize = 0;3431 var i: usize = 0;
3432 while (i < free_list.items.len) {3432 while (i < free_list.items.len) {
3433 const big_atom_index = free_list.items[i];3433 const big_atom_index = free_list.items[i];
...@@ -3971,7 +3971,7 @@ fn writeDyldInfoData(self: *MachO) !void {...@@ -3971,7 +3971,7 @@ fn writeDyldInfoData(self: *MachO) !void {
3971 link_seg.filesize = needed_size;3971 link_seg.filesize = needed_size;
3972 assert(mem.isAlignedGeneric(u64, link_seg.fileoff + link_seg.filesize, @alignOf(u64)));3972 assert(mem.isAlignedGeneric(u64, link_seg.fileoff + link_seg.filesize, @alignOf(u64)));
39733973
3974 var buffer = try gpa.alloc(u8, needed_size);3974 const buffer = try gpa.alloc(u8, needed_size);
3975 defer gpa.free(buffer);3975 defer gpa.free(buffer);
3976 @memset(buffer, 0);3976 @memset(buffer, 0);
39773977
...@@ -5228,7 +5228,7 @@ fn reportMissingLibraryError(...@@ -5228,7 +5228,7 @@ fn reportMissingLibraryError(
5228) error{OutOfMemory}!void {5228) error{OutOfMemory}!void {
5229 const gpa = self.base.allocator;5229 const gpa = self.base.allocator;
5230 try self.misc_errors.ensureUnusedCapacity(gpa, 1);5230 try self.misc_errors.ensureUnusedCapacity(gpa, 1);
5231 var notes = try gpa.alloc(File.ErrorMsg, checked_paths.len);5231 const notes = try gpa.alloc(File.ErrorMsg, checked_paths.len);
5232 errdefer gpa.free(notes);5232 errdefer gpa.free(notes);
5233 for (checked_paths, notes) |path, *note| {5233 for (checked_paths, notes) |path, *note| {
5234 note.* = .{ .msg = try std.fmt.allocPrint(gpa, "tried {s}", .{path}) };5234 note.* = .{ .msg = try std.fmt.allocPrint(gpa, "tried {s}", .{path}) };
src/link/MachO/Archive.zig+3-3
...@@ -98,7 +98,7 @@ pub fn parse(self: *Archive, allocator: Allocator, reader: anytype) !void {...@@ -98,7 +98,7 @@ pub fn parse(self: *Archive, allocator: Allocator, reader: anytype) !void {
98 _ = try reader.readBytesNoEof(SARMAG);98 _ = try reader.readBytesNoEof(SARMAG);
99 self.header = try reader.readStruct(ar_hdr);99 self.header = try reader.readStruct(ar_hdr);
100 const name_or_length = try self.header.nameOrLength();100 const name_or_length = try self.header.nameOrLength();
101 var embedded_name = try parseName(allocator, name_or_length, reader);101 const embedded_name = try parseName(allocator, name_or_length, reader);
102 log.debug("parsing archive '{s}' at '{s}'", .{ embedded_name, self.name });102 log.debug("parsing archive '{s}' at '{s}'", .{ embedded_name, self.name });
103 defer allocator.free(embedded_name);103 defer allocator.free(embedded_name);
104104
...@@ -124,7 +124,7 @@ fn parseName(allocator: Allocator, name_or_length: ar_hdr.NameOrLength, reader:...@@ -124,7 +124,7 @@ fn parseName(allocator: Allocator, name_or_length: ar_hdr.NameOrLength, reader:
124124
125fn parseTableOfContents(self: *Archive, allocator: Allocator, reader: anytype) !void {125fn parseTableOfContents(self: *Archive, allocator: Allocator, reader: anytype) !void {
126 const symtab_size = try reader.readInt(u32, .little);126 const symtab_size = try reader.readInt(u32, .little);
127 var symtab = try allocator.alloc(u8, symtab_size);127 const symtab = try allocator.alloc(u8, symtab_size);
128 defer allocator.free(symtab);128 defer allocator.free(symtab);
129129
130 reader.readNoEof(symtab) catch {130 reader.readNoEof(symtab) catch {
...@@ -133,7 +133,7 @@ fn parseTableOfContents(self: *Archive, allocator: Allocator, reader: anytype) !...@@ -133,7 +133,7 @@ fn parseTableOfContents(self: *Archive, allocator: Allocator, reader: anytype) !
133 };133 };
134134
135 const strtab_size = try reader.readInt(u32, .little);135 const strtab_size = try reader.readInt(u32, .little);
136 var strtab = try allocator.alloc(u8, strtab_size);136 const strtab = try allocator.alloc(u8, strtab_size);
137 defer allocator.free(strtab);137 defer allocator.free(strtab);
138138
139 reader.readNoEof(strtab) catch {139 reader.readNoEof(strtab) catch {
src/link/MachO/Dylib.zig+3-3
...@@ -167,7 +167,7 @@ pub fn parseFromBinary(...@@ -167,7 +167,7 @@ pub fn parseFromBinary(
167 .REEXPORT_DYLIB => {167 .REEXPORT_DYLIB => {
168 if (should_lookup_reexports) {168 if (should_lookup_reexports) {
169 // Parse install_name to dependent dylib.169 // Parse install_name to dependent dylib.
170 var id = try Id.fromLoadCommand(170 const id = try Id.fromLoadCommand(
171 allocator,171 allocator,
172 cmd.cast(macho.dylib_command).?,172 cmd.cast(macho.dylib_command).?,
173 cmd.getDylibPathName(),173 cmd.getDylibPathName(),
...@@ -410,7 +410,7 @@ pub fn parseFromStub(...@@ -410,7 +410,7 @@ pub fn parseFromStub(
410410
411 log.debug(" (found re-export '{s}')", .{lib});411 log.debug(" (found re-export '{s}')", .{lib});
412412
413 var dep_id = try Id.default(allocator, lib);413 const dep_id = try Id.default(allocator, lib);
414 try dependent_libs.writeItem(.{ .id = dep_id, .parent = dylib_id });414 try dependent_libs.writeItem(.{ .id = dep_id, .parent = dylib_id });
415 }415 }
416 }416 }
...@@ -527,7 +527,7 @@ pub fn parseFromStub(...@@ -527,7 +527,7 @@ pub fn parseFromStub(
527527
528 log.debug(" (found re-export '{s}')", .{lib});528 log.debug(" (found re-export '{s}')", .{lib});
529529
530 var dep_id = try Id.default(allocator, lib);530 const dep_id = try Id.default(allocator, lib);
531 try dependent_libs.writeItem(.{ .id = dep_id, .parent = dylib_id });531 try dependent_libs.writeItem(.{ .id = dep_id, .parent = dylib_id });
532 }532 }
533 }533 }
src/link/MachO/Trie.zig+8-8
...@@ -150,7 +150,7 @@ pub fn deinit(self: *Trie, allocator: Allocator) void {...@@ -150,7 +150,7 @@ pub fn deinit(self: *Trie, allocator: Allocator) void {
150}150}
151151
152test "Trie node count" {152test "Trie node count" {
153 var gpa = testing.allocator;153 const gpa = testing.allocator;
154 var trie: Trie = .{};154 var trie: Trie = .{};
155 defer trie.deinit(gpa);155 defer trie.deinit(gpa);
156 try trie.init(gpa);156 try trie.init(gpa);
...@@ -196,7 +196,7 @@ test "Trie node count" {...@@ -196,7 +196,7 @@ test "Trie node count" {
196}196}
197197
198test "Trie basic" {198test "Trie basic" {
199 var gpa = testing.allocator;199 const gpa = testing.allocator;
200 var trie: Trie = .{};200 var trie: Trie = .{};
201 defer trie.deinit(gpa);201 defer trie.deinit(gpa);
202 try trie.init(gpa);202 try trie.init(gpa);
...@@ -254,7 +254,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8) !void {...@@ -254,7 +254,7 @@ fn expectEqualHexStrings(expected: []const u8, given: []const u8) !void {
254 const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{std.fmt.fmtSliceHexLower(given)});254 const given_fmt = try std.fmt.allocPrint(testing.allocator, "{x}", .{std.fmt.fmtSliceHexLower(given)});
255 defer testing.allocator.free(given_fmt);255 defer testing.allocator.free(given_fmt);
256 const idx = mem.indexOfDiff(u8, expected_fmt, given_fmt).?;256 const idx = mem.indexOfDiff(u8, expected_fmt, given_fmt).?;
257 var padding = try testing.allocator.alloc(u8, idx + 5);257 const padding = try testing.allocator.alloc(u8, idx + 5);
258 defer testing.allocator.free(padding);258 defer testing.allocator.free(padding);
259 @memset(padding, ' ');259 @memset(padding, ' ');
260 std.debug.print("\nEXP: {s}\nGIV: {s}\n{s}^ -- first differing byte\n", .{ expected_fmt, given_fmt, padding });260 std.debug.print("\nEXP: {s}\nGIV: {s}\n{s}^ -- first differing byte\n", .{ expected_fmt, given_fmt, padding });
...@@ -292,7 +292,7 @@ test "write Trie to a byte stream" {...@@ -292,7 +292,7 @@ test "write Trie to a byte stream" {
292 0x3, 0x0, 0x80, 0x20, 0x0, // terminal node292 0x3, 0x0, 0x80, 0x20, 0x0, // terminal node
293 };293 };
294294
295 var buffer = try gpa.alloc(u8, trie.size);295 const buffer = try gpa.alloc(u8, trie.size);
296 defer gpa.free(buffer);296 defer gpa.free(buffer);
297 var stream = std.io.fixedBufferStream(buffer);297 var stream = std.io.fixedBufferStream(buffer);
298 {298 {
...@@ -331,7 +331,7 @@ test "parse Trie from byte stream" {...@@ -331,7 +331,7 @@ test "parse Trie from byte stream" {
331331
332 try trie.finalize(gpa);332 try trie.finalize(gpa);
333333
334 var out_buffer = try gpa.alloc(u8, trie.size);334 const out_buffer = try gpa.alloc(u8, trie.size);
335 defer gpa.free(out_buffer);335 defer gpa.free(out_buffer);
336 var out_stream = std.io.fixedBufferStream(out_buffer);336 var out_stream = std.io.fixedBufferStream(out_buffer);
337 _ = try trie.write(out_stream.writer());337 _ = try trie.write(out_stream.writer());
...@@ -362,7 +362,7 @@ test "ordering bug" {...@@ -362,7 +362,7 @@ test "ordering bug" {
362 0x00, 0x12, 0x03, 0x00, 0xD8, 0x0A, 0x00,362 0x00, 0x12, 0x03, 0x00, 0xD8, 0x0A, 0x00,
363 };363 };
364364
365 var buffer = try gpa.alloc(u8, trie.size);365 const buffer = try gpa.alloc(u8, trie.size);
366 defer gpa.free(buffer);366 defer gpa.free(buffer);
367 var stream = std.io.fixedBufferStream(buffer);367 var stream = std.io.fixedBufferStream(buffer);
368 // Writing finalized trie again should yield the same result.368 // Writing finalized trie again should yield the same result.
...@@ -426,7 +426,7 @@ pub const Node = struct {...@@ -426,7 +426,7 @@ pub const Node = struct {
426 // To: A -> C -> B426 // To: A -> C -> B
427 const mid = try allocator.create(Node);427 const mid = try allocator.create(Node);
428 mid.* = .{ .base = self.base };428 mid.* = .{ .base = self.base };
429 var to_label = try allocator.dupe(u8, edge.label[match..]);429 const to_label = try allocator.dupe(u8, edge.label[match..]);
430 allocator.free(edge.label);430 allocator.free(edge.label);
431 const to_node = edge.to;431 const to_node = edge.to;
432 edge.to = mid;432 edge.to = mid;
...@@ -573,7 +573,7 @@ pub const Node = struct {...@@ -573,7 +573,7 @@ pub const Node = struct {
573 /// Updates offset of this node in the output byte stream.573 /// Updates offset of this node in the output byte stream.
574 fn finalize(self: *Node, offset_in_trie: u64) !FinalizeResult {574 fn finalize(self: *Node, offset_in_trie: u64) !FinalizeResult {
575 var stream = std.io.countingWriter(std.io.null_writer);575 var stream = std.io.countingWriter(std.io.null_writer);
576 var writer = stream.writer();576 const writer = stream.writer();
577577
578 var node_size: u64 = 0;578 var node_size: u64 = 0;
579 if (self.terminal_info) |info| {579 if (self.terminal_info) |info| {
src/link/MachO/UnwindInfo.zig+1-1
...@@ -417,7 +417,7 @@ pub fn collect(info: *UnwindInfo, macho_file: *MachO) !void {...@@ -417,7 +417,7 @@ pub fn collect(info: *UnwindInfo, macho_file: *MachO) !void {
417 gop.value_ptr.count += 1;417 gop.value_ptr.count += 1;
418 }418 }
419419
420 var slice = common_encodings_counts.values();420 const slice = common_encodings_counts.values();
421 mem.sort(CommonEncWithCount, slice, {}, CommonEncWithCount.greaterThan);421 mem.sort(CommonEncWithCount, slice, {}, CommonEncWithCount.greaterThan);
422422
423 var i: u7 = 0;423 var i: u7 = 0;
src/link/MachO/eh_frame.zig+1-1
...@@ -586,7 +586,7 @@ pub const Iterator = struct {...@@ -586,7 +586,7 @@ pub const Iterator = struct {
586 var stream = std.io.fixedBufferStream(it.data[it.pos..]);586 var stream = std.io.fixedBufferStream(it.data[it.pos..]);
587 const reader = stream.reader();587 const reader = stream.reader();
588588
589 var size = try reader.readInt(u32, .little);589 const size = try reader.readInt(u32, .little);
590 if (size == 0xFFFFFFFF) {590 if (size == 0xFFFFFFFF) {
591 log.debug("MachO doesn't support 64bit DWARF CFI __eh_frame records", .{});591 log.debug("MachO doesn't support 64bit DWARF CFI __eh_frame records", .{});
592 return error.BadDwarfCfi;592 return error.BadDwarfCfi;
src/link/MachO/load_commands.zig+1-1
...@@ -112,7 +112,7 @@ pub fn calcMinHeaderPad(gpa: Allocator, options: *const link.Options, ctx: CalcL...@@ -112,7 +112,7 @@ pub fn calcMinHeaderPad(gpa: Allocator, options: *const link.Options, ctx: CalcL
112 log.debug("minimum requested headerpad size 0x{x}", .{padding + @sizeOf(macho.mach_header_64)});112 log.debug("minimum requested headerpad size 0x{x}", .{padding + @sizeOf(macho.mach_header_64)});
113113
114 if (options.headerpad_max_install_names) {114 if (options.headerpad_max_install_names) {
115 var min_headerpad_size: u32 = try calcLCsSize(gpa, options, ctx, true);115 const min_headerpad_size: u32 = try calcLCsSize(gpa, options, ctx, true);
116 log.debug("headerpad_max_install_names minimum headerpad size 0x{x}", .{116 log.debug("headerpad_max_install_names minimum headerpad size 0x{x}", .{
117 min_headerpad_size + @sizeOf(macho.mach_header_64),117 min_headerpad_size + @sizeOf(macho.mach_header_64),
118 });118 });
src/link/MachO/zld.zig+1-1
...@@ -503,7 +503,7 @@ pub fn linkWithZld(...@@ -503,7 +503,7 @@ pub fn linkWithZld(
503 const size = math.cast(usize, linkedit.fileoff - start) orelse return error.Overflow;503 const size = math.cast(usize, linkedit.fileoff - start) orelse return error.Overflow;
504 if (size > 0) {504 if (size > 0) {
505 log.debug("zeroing out zerofill area of length {x} at {x}", .{ size, start });505 log.debug("zeroing out zerofill area of length {x} at {x}", .{ size, start });
506 var padding = try gpa.alloc(u8, size);506 const padding = try gpa.alloc(u8, size);
507 defer gpa.free(padding);507 defer gpa.free(padding);
508 @memset(padding, 0);508 @memset(padding, 0);
509 try macho_file.base.file.?.pwriteAll(padding, start);509 try macho_file.base.file.?.pwriteAll(padding, start);
src/link/Plan9.zig+6-6
...@@ -300,7 +300,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Plan9 {...@@ -300,7 +300,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Plan9 {
300 else => return error.UnsupportedP9Architecture,300 else => return error.UnsupportedP9Architecture,
301 };301 };
302302
303 var arena_allocator = std.heap.ArenaAllocator.init(gpa);303 const arena_allocator = std.heap.ArenaAllocator.init(gpa);
304304
305 const self = try gpa.create(Plan9);305 const self = try gpa.create(Plan9);
306 self.* = .{306 self.* = .{
...@@ -467,7 +467,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.I...@@ -467,7 +467,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.I
467467
468 const sym_index = try self.allocateSymbolIndex();468 const sym_index = try self.allocateSymbolIndex();
469 const new_atom_idx = try self.createAtom();469 const new_atom_idx = try self.createAtom();
470 var info: Atom = .{470 const info: Atom = .{
471 .type = .d,471 .type = .d,
472 .offset = null,472 .offset = null,
473 .sym_index = sym_index,473 .sym_index = sym_index,
...@@ -496,7 +496,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.I...@@ -496,7 +496,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.I
496 },496 },
497 };497 };
498 // duped_code is freed when the unnamed const is freed498 // duped_code is freed when the unnamed const is freed
499 var duped_code = try self.base.allocator.dupe(u8, code);499 const duped_code = try self.base.allocator.dupe(u8, code);
500 errdefer self.base.allocator.free(duped_code);500 errdefer self.base.allocator.free(duped_code);
501 const new_atom = self.getAtomPtr(new_atom_idx);501 const new_atom = self.getAtomPtr(new_atom_idx);
502 new_atom.* = info;502 new_atom.* = info;
...@@ -1024,7 +1024,7 @@ pub fn freeDecl(self: *Plan9, decl_index: Module.Decl.Index) void {...@@ -1024,7 +1024,7 @@ pub fn freeDecl(self: *Plan9, decl_index: Module.Decl.Index) void {
1024 const decl = mod.declPtr(decl_index);1024 const decl = mod.declPtr(decl_index);
1025 const is_fn = decl.val.isFuncBody(mod);1025 const is_fn = decl.val.isFuncBody(mod);
1026 if (is_fn) {1026 if (is_fn) {
1027 var symidx_and_submap = self.fn_decl_table.get(decl.getFileScope(mod)).?;1027 const symidx_and_submap = self.fn_decl_table.get(decl.getFileScope(mod)).?;
1028 var submap = symidx_and_submap.functions;1028 var submap = symidx_and_submap.functions;
1029 if (submap.fetchSwapRemove(decl_index)) |removed_entry| {1029 if (submap.fetchSwapRemove(decl_index)) |removed_entry| {
1030 self.base.allocator.free(removed_entry.value.code);1030 self.base.allocator.free(removed_entry.value.code);
...@@ -1204,7 +1204,7 @@ fn updateLazySymbolAtom(self: *Plan9, sym: File.LazySymbol, atom_index: Atom.Ind...@@ -1204,7 +1204,7 @@ fn updateLazySymbolAtom(self: *Plan9, sym: File.LazySymbol, atom_index: Atom.Ind
1204 },1204 },
1205 };1205 };
1206 // duped_code is freed when the atom is freed1206 // duped_code is freed when the atom is freed
1207 var duped_code = try self.base.allocator.dupe(u8, code);1207 const duped_code = try self.base.allocator.dupe(u8, code);
1208 errdefer self.base.allocator.free(duped_code);1208 errdefer self.base.allocator.free(duped_code);
1209 self.getAtomPtr(atom_index).code = .{1209 self.getAtomPtr(atom_index).code = .{
1210 .code_ptr = duped_code.ptr,1210 .code_ptr = duped_code.ptr,
...@@ -1489,7 +1489,7 @@ pub fn lowerAnonDecl(self: *Plan9, decl_val: InternPool.Index, src_loc: Module.S...@@ -1489,7 +1489,7 @@ pub fn lowerAnonDecl(self: *Plan9, decl_val: InternPool.Index, src_loc: Module.S
1489 // to put it in some location.1489 // to put it in some location.
1490 // ...1490 // ...
1491 const gpa = self.base.allocator;1491 const gpa = self.base.allocator;
1492 var gop = try self.anon_decls.getOrPut(gpa, decl_val);1492 const gop = try self.anon_decls.getOrPut(gpa, decl_val);
1493 const mod = self.base.options.module.?;1493 const mod = self.base.options.module.?;
1494 if (!gop.found_existing) {1494 if (!gop.found_existing) {
1495 const ty = mod.intern_pool.typeOf(decl_val).toType();1495 const ty = mod.intern_pool.typeOf(decl_val).toType();
src/link/Wasm.zig+5-5
...@@ -860,7 +860,7 @@ fn resolveSymbolsInArchives(wasm: *Wasm) !void {...@@ -860,7 +860,7 @@ fn resolveSymbolsInArchives(wasm: *Wasm) !void {
860 // Parse object and and resolve symbols again before we check remaining860 // Parse object and and resolve symbols again before we check remaining
861 // undefined symbols.861 // undefined symbols.
862 const object_file_index = @as(u16, @intCast(wasm.objects.items.len));862 const object_file_index = @as(u16, @intCast(wasm.objects.items.len));
863 var object = try archive.parseObject(wasm.base.allocator, offset.items[0]);863 const object = try archive.parseObject(wasm.base.allocator, offset.items[0]);
864 try wasm.objects.append(wasm.base.allocator, object);864 try wasm.objects.append(wasm.base.allocator, object);
865 try wasm.resolveSymbolsInObject(object_file_index);865 try wasm.resolveSymbolsInObject(object_file_index);
866866
...@@ -1344,7 +1344,7 @@ pub fn deinit(wasm: *Wasm) void {...@@ -1344,7 +1344,7 @@ pub fn deinit(wasm: *Wasm) void {
1344/// Will re-use slots when a symbol was freed at an earlier stage.1344/// Will re-use slots when a symbol was freed at an earlier stage.
1345pub fn allocateSymbol(wasm: *Wasm) !u32 {1345pub fn allocateSymbol(wasm: *Wasm) !u32 {
1346 try wasm.symbols.ensureUnusedCapacity(wasm.base.allocator, 1);1346 try wasm.symbols.ensureUnusedCapacity(wasm.base.allocator, 1);
1347 var symbol: Symbol = .{1347 const symbol: Symbol = .{
1348 .name = std.math.maxInt(u32), // will be set after updateDecl as well as during atom creation for decls1348 .name = std.math.maxInt(u32), // will be set after updateDecl as well as during atom creation for decls
1349 .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL),1349 .flags = @intFromEnum(Symbol.Flag.WASM_SYM_BINDING_LOCAL),
1350 .tag = .undefined, // will be set after updateDecl1350 .tag = .undefined, // will be set after updateDecl
...@@ -1655,7 +1655,7 @@ pub fn getGlobalSymbol(wasm: *Wasm, name: []const u8, lib_name: ?[]const u8) !u3...@@ -1655,7 +1655,7 @@ pub fn getGlobalSymbol(wasm: *Wasm, name: []const u8, lib_name: ?[]const u8) !u3
1655 symbol.setUndefined(true);1655 symbol.setUndefined(true);
16561656
1657 const sym_index = if (wasm.symbols_free_list.popOrNull()) |index| index else blk: {1657 const sym_index = if (wasm.symbols_free_list.popOrNull()) |index| index else blk: {
1658 var index = @as(u32, @intCast(wasm.symbols.items.len));1658 const index: u32 = @intCast(wasm.symbols.items.len);
1659 try wasm.symbols.ensureUnusedCapacity(wasm.base.allocator, 1);1659 try wasm.symbols.ensureUnusedCapacity(wasm.base.allocator, 1);
1660 wasm.symbols.items.len += 1;1660 wasm.symbols.items.len += 1;
1661 break :blk index;1661 break :blk index;
...@@ -2632,7 +2632,7 @@ fn setupImports(wasm: *Wasm) !void {...@@ -2632,7 +2632,7 @@ fn setupImports(wasm: *Wasm) !void {
26322632
2633 // We copy the import to a new import to ensure the names contain references2633 // We copy the import to a new import to ensure the names contain references
2634 // to the internal string table, rather than of the object file.2634 // to the internal string table, rather than of the object file.
2635 var new_imp: types.Import = .{2635 const new_imp: types.Import = .{
2636 .module_name = try wasm.string_table.put(wasm.base.allocator, object.string_table.get(import.module_name)),2636 .module_name = try wasm.string_table.put(wasm.base.allocator, object.string_table.get(import.module_name)),
2637 .name = try wasm.string_table.put(wasm.base.allocator, object.string_table.get(import.name)),2637 .name = try wasm.string_table.put(wasm.base.allocator, object.string_table.get(import.name)),
2638 .kind = import.kind,2638 .kind = import.kind,
...@@ -3800,7 +3800,7 @@ fn writeToFile(...@@ -3800,7 +3800,7 @@ fn writeToFile(
3800 const table_loc = wasm.findGlobalSymbol("__indirect_function_table").?;3800 const table_loc = wasm.findGlobalSymbol("__indirect_function_table").?;
3801 const table_sym = table_loc.getSymbol(wasm);3801 const table_sym = table_loc.getSymbol(wasm);
38023802
3803 var flags: u32 = if (table_sym.index == 0) 0x0 else 0x02; // passive with implicit 0-index table or set table index manually3803 const flags: u32 = if (table_sym.index == 0) 0x0 else 0x02; // passive with implicit 0-index table or set table index manually
3804 try leb.writeULEB128(binary_writer, flags);3804 try leb.writeULEB128(binary_writer, flags);
3805 if (flags == 0x02) {3805 if (flags == 0x02) {
3806 try leb.writeULEB128(binary_writer, table_sym.index);3806 try leb.writeULEB128(binary_writer, table_sym.index);
src/link/Wasm/Object.zig+3-3
...@@ -252,7 +252,7 @@ fn checkLegacyIndirectFunctionTable(object: *Object) !?Symbol {...@@ -252,7 +252,7 @@ fn checkLegacyIndirectFunctionTable(object: *Object) !?Symbol {
252 return error.MissingTableSymbols;252 return error.MissingTableSymbols;
253 }253 }
254254
255 var table_import: types.Import = for (object.imports) |imp| {255 const table_import: types.Import = for (object.imports) |imp| {
256 if (imp.kind == .table) {256 if (imp.kind == .table) {
257 break imp;257 break imp;
258 }258 }
...@@ -512,7 +512,7 @@ fn Parser(comptime ReaderType: type) type {...@@ -512,7 +512,7 @@ fn Parser(comptime ReaderType: type) type {
512 try assertEnd(reader);512 try assertEnd(reader);
513 },513 },
514 .code => {514 .code => {
515 var start = reader.context.bytes_left;515 const start = reader.context.bytes_left;
516 var index: u32 = 0;516 var index: u32 = 0;
517 const count = try readLeb(u32, reader);517 const count = try readLeb(u32, reader);
518 while (index < count) : (index += 1) {518 while (index < count) : (index += 1) {
...@@ -532,7 +532,7 @@ fn Parser(comptime ReaderType: type) type {...@@ -532,7 +532,7 @@ fn Parser(comptime ReaderType: type) type {
532 }532 }
533 },533 },
534 .data => {534 .data => {
535 var start = reader.context.bytes_left;535 const start = reader.context.bytes_left;
536 var index: u32 = 0;536 var index: u32 = 0;
537 const count = try readLeb(u32, reader);537 const count = try readLeb(u32, reader);
538 while (index < count) : (index += 1) {538 while (index < count) : (index += 1) {
src/link/tapi/yaml.zig+1-1
...@@ -491,7 +491,7 @@ pub fn stringify(allocator: Allocator, input: anytype, writer: anytype) !void {...@@ -491,7 +491,7 @@ pub fn stringify(allocator: Allocator, input: anytype, writer: anytype) !void {
491 var arena = ArenaAllocator.init(allocator);491 var arena = ArenaAllocator.init(allocator);
492 defer arena.deinit();492 defer arena.deinit();
493493
494 var maybe_value = try Value.encode(arena.allocator(), input);494 const maybe_value = try Value.encode(arena.allocator(), input);
495495
496 if (maybe_value) |value| {496 if (maybe_value) |value| {
497 // TODO should we output as an explicit doc?497 // TODO should we output as an explicit doc?
src/main.zig+7-7
...@@ -4479,7 +4479,7 @@ fn cmdRc(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -4479,7 +4479,7 @@ fn cmdRc(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
4479 try stdout_writer.writeByte('\n');4479 try stdout_writer.writeByte('\n');
4480 }4480 }
44814481
4482 var full_input = full_input: {4482 const full_input = full_input: {
4483 if (options.preprocess != .no) {4483 if (options.preprocess != .no) {
4484 if (!build_options.have_llvm) {4484 if (!build_options.have_llvm) {
4485 fatal("clang not available: compiler built without LLVM extensions", .{});4485 fatal("clang not available: compiler built without LLVM extensions", .{});
...@@ -4526,7 +4526,7 @@ fn cmdRc(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -4526,7 +4526,7 @@ fn cmdRc(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
4526 }4526 }
45274527
4528 if (process.can_spawn) {4528 if (process.can_spawn) {
4529 var result = std.ChildProcess.run(.{4529 const result = std.ChildProcess.run(.{
4530 .allocator = gpa,4530 .allocator = gpa,
4531 .argv = argv.items,4531 .argv = argv.items,
4532 .max_output_bytes = std.math.maxInt(u32),4532 .max_output_bytes = std.math.maxInt(u32),
...@@ -4593,7 +4593,7 @@ fn cmdRc(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -4593,7 +4593,7 @@ fn cmdRc(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
4593 var mapping_results = try resinator.source_mapping.parseAndRemoveLineCommands(gpa, full_input, full_input, .{ .initial_filename = options.input_filename });4593 var mapping_results = try resinator.source_mapping.parseAndRemoveLineCommands(gpa, full_input, full_input, .{ .initial_filename = options.input_filename });
4594 defer mapping_results.mappings.deinit(gpa);4594 defer mapping_results.mappings.deinit(gpa);
45954595
4596 var final_input = resinator.comments.removeComments(mapping_results.result, mapping_results.result, &mapping_results.mappings);4596 const final_input = resinator.comments.removeComments(mapping_results.result, mapping_results.result, &mapping_results.mappings);
45974597
4598 var output_file = std.fs.cwd().createFile(options.output_filename, .{}) catch |err| {4598 var output_file = std.fs.cwd().createFile(options.output_filename, .{}) catch |err| {
4599 try resinator.utils.renderErrorMessage(stderr.writer(), stderr_config, .err, "unable to create output file '{s}': {s}", .{ options.output_filename, @errorName(err) });4599 try resinator.utils.renderErrorMessage(stderr.writer(), stderr_config, .err, "unable to create output file '{s}': {s}", .{ options.output_filename, @errorName(err) });
...@@ -4762,7 +4762,7 @@ pub fn cmdLibC(gpa: Allocator, args: []const []const u8) !void {...@@ -4762,7 +4762,7 @@ pub fn cmdLibC(gpa: Allocator, args: []const []const u8) !void {
47624762
4763 const libc_installation: ?*LibCInstallation = libc: {4763 const libc_installation: ?*LibCInstallation = libc: {
4764 if (input_file) |libc_file| {4764 if (input_file) |libc_file| {
4765 var libc = try arena.create(LibCInstallation);4765 const libc = try arena.create(LibCInstallation);
4766 libc.* = LibCInstallation.parse(arena, libc_file, cross_target) catch |err| {4766 libc.* = LibCInstallation.parse(arena, libc_file, cross_target) catch |err| {
4767 fatal("unable to parse libc file at path {s}: {s}", .{ libc_file, @errorName(err) });4767 fatal("unable to parse libc file at path {s}: {s}", .{ libc_file, @errorName(err) });
4768 };4768 };
...@@ -4781,7 +4781,7 @@ pub fn cmdLibC(gpa: Allocator, args: []const []const u8) !void {...@@ -4781,7 +4781,7 @@ pub fn cmdLibC(gpa: Allocator, args: []const []const u8) !void {
4781 const target = cross_target.toTarget();4781 const target = cross_target.toTarget();
4782 const is_native_abi = cross_target.isNativeAbi();4782 const is_native_abi = cross_target.isNativeAbi();
47834783
4784 var libc_dirs = Compilation.detectLibCIncludeDirs(4784 const libc_dirs = Compilation.detectLibCIncludeDirs(
4785 arena,4785 arena,
4786 zig_lib_directory.path.?,4786 zig_lib_directory.path.?,
4787 target,4787 target,
...@@ -4960,7 +4960,7 @@ pub const usage_build =...@@ -4960,7 +4960,7 @@ pub const usage_build =
4960pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {4960pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
4961 const work_around_btrfs_bug = builtin.os.tag == .linux and4961 const work_around_btrfs_bug = builtin.os.tag == .linux and
4962 EnvVar.ZIG_BTRFS_WORKAROUND.isSet();4962 EnvVar.ZIG_BTRFS_WORKAROUND.isSet();
4963 var color: Color = .auto;4963 const color: Color = .auto;
49644964
4965 // We want to release all the locks before executing the child process, so we make a nice4965 // We want to release all the locks before executing the child process, so we make a nice
4966 // big block here to ensure the cleanup gets run when we extract out our argv.4966 // big block here to ensure the cleanup gets run when we extract out our argv.
...@@ -6001,7 +6001,7 @@ const ArgIteratorResponseFile = process.ArgIteratorGeneral(.{ .comments = true,...@@ -6001,7 +6001,7 @@ const ArgIteratorResponseFile = process.ArgIteratorGeneral(.{ .comments = true,
6001/// Initialize the arguments from a Response File. "*.rsp"6001/// Initialize the arguments from a Response File. "*.rsp"
6002fn initArgIteratorResponseFile(allocator: Allocator, resp_file_path: []const u8) !ArgIteratorResponseFile {6002fn initArgIteratorResponseFile(allocator: Allocator, resp_file_path: []const u8) !ArgIteratorResponseFile {
6003 const max_bytes = 10 * 1024 * 1024; // 10 MiB of command line arguments is a reasonable limit6003 const max_bytes = 10 * 1024 * 1024; // 10 MiB of command line arguments is a reasonable limit
6004 var cmd_line = try fs.cwd().readFileAlloc(allocator, resp_file_path, max_bytes);6004 const cmd_line = try fs.cwd().readFileAlloc(allocator, resp_file_path, max_bytes);
6005 errdefer allocator.free(cmd_line);6005 errdefer allocator.free(cmd_line);
60066006
6007 return ArgIteratorResponseFile.initTakeOwnership(allocator, cmd_line);6007 return ArgIteratorResponseFile.initTakeOwnership(allocator, cmd_line);
src/resinator/bmp.zig+1-1
...@@ -120,7 +120,7 @@ pub fn read(reader: anytype, max_size: u64) ReadError!BitmapInfo {...@@ -120,7 +120,7 @@ pub fn read(reader: anytype, max_size: u64) ReadError!BitmapInfo {
120 var dib_header_buf: [@sizeOf(BITMAPCOREHEADER)]u8 align(@alignOf(BITMAPCOREHEADER)) = undefined;120 var dib_header_buf: [@sizeOf(BITMAPCOREHEADER)]u8 align(@alignOf(BITMAPCOREHEADER)) = undefined;
121 std.mem.writeInt(u32, dib_header_buf[0..4], bitmap_info.dib_header_size, .little);121 std.mem.writeInt(u32, dib_header_buf[0..4], bitmap_info.dib_header_size, .little);
122 reader.readNoEof(dib_header_buf[4..]) catch return error.UnexpectedEOF;122 reader.readNoEof(dib_header_buf[4..]) catch return error.UnexpectedEOF;
123 var dib_header: *BITMAPCOREHEADER = @ptrCast(&dib_header_buf);123 const dib_header: *BITMAPCOREHEADER = @ptrCast(&dib_header_buf);
124 structFieldsLittleToNative(BITMAPCOREHEADER, dib_header);124 structFieldsLittleToNative(BITMAPCOREHEADER, dib_header);
125125
126 // > The size of the color palette is calculated from the BitsPerPixel value.126 // > The size of the color palette is calculated from the BitsPerPixel value.
src/resinator/cli.zig+5-5
...@@ -163,15 +163,15 @@ pub const Options = struct {...@@ -163,15 +163,15 @@ pub const Options = struct {
163 // we shouldn't change anything.163 // we shouldn't change anything.
164 if (val_ptr.* == .undefine) return;164 if (val_ptr.* == .undefine) return;
165 // Otherwise, the new value takes precedence.165 // Otherwise, the new value takes precedence.
166 var duped_value = try self.allocator.dupe(u8, value);166 const duped_value = try self.allocator.dupe(u8, value);
167 errdefer self.allocator.free(duped_value);167 errdefer self.allocator.free(duped_value);
168 val_ptr.deinit(self.allocator);168 val_ptr.deinit(self.allocator);
169 val_ptr.* = .{ .define = duped_value };169 val_ptr.* = .{ .define = duped_value };
170 return;170 return;
171 }171 }
172 var duped_key = try self.allocator.dupe(u8, identifier);172 const duped_key = try self.allocator.dupe(u8, identifier);
173 errdefer self.allocator.free(duped_key);173 errdefer self.allocator.free(duped_key);
174 var duped_value = try self.allocator.dupe(u8, value);174 const duped_value = try self.allocator.dupe(u8, value);
175 errdefer self.allocator.free(duped_value);175 errdefer self.allocator.free(duped_value);
176 try self.symbols.put(self.allocator, duped_key, .{ .define = duped_value });176 try self.symbols.put(self.allocator, duped_key, .{ .define = duped_value });
177 }177 }
...@@ -183,7 +183,7 @@ pub const Options = struct {...@@ -183,7 +183,7 @@ pub const Options = struct {
183 action.* = .{ .undefine = {} };183 action.* = .{ .undefine = {} };
184 return;184 return;
185 }185 }
186 var duped_key = try self.allocator.dupe(u8, identifier);186 const duped_key = try self.allocator.dupe(u8, identifier);
187 errdefer self.allocator.free(duped_key);187 errdefer self.allocator.free(duped_key);
188 try self.symbols.put(self.allocator, duped_key, .{ .undefine = {} });188 try self.symbols.put(self.allocator, duped_key, .{ .undefine = {} });
189 }189 }
...@@ -828,7 +828,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn...@@ -828,7 +828,7 @@ pub fn parse(allocator: Allocator, args: []const []const u8, diagnostics: *Diagn
828 }828 }
829 }829 }
830830
831 var positionals = args[arg_i..];831 const positionals = args[arg_i..];
832832
833 if (positionals.len < 1) {833 if (positionals.len < 1) {
834 var err_details = Diagnostics.ErrorDetails{ .print_args = false, .arg_index = arg_i };834 var err_details = Diagnostics.ErrorDetails{ .print_args = false, .arg_index = arg_i };
src/resinator/code_pages.zig+3-3
...@@ -302,8 +302,8 @@ pub const Utf8 = struct {...@@ -302,8 +302,8 @@ pub const Utf8 = struct {
302302
303 pub fn decode(bytes: []const u8) Codepoint {303 pub fn decode(bytes: []const u8) Codepoint {
304 std.debug.assert(bytes.len > 0);304 std.debug.assert(bytes.len > 0);
305 var first_byte = bytes[0];305 const first_byte = bytes[0];
306 var expected_len = sequenceLength(first_byte) orelse {306 const expected_len = sequenceLength(first_byte) orelse {
307 return .{ .value = Codepoint.invalid, .byte_len = 1 };307 return .{ .value = Codepoint.invalid, .byte_len = 1 };
308 };308 };
309 if (expected_len == 1) return .{ .value = first_byte, .byte_len = 1 };309 if (expected_len == 1) return .{ .value = first_byte, .byte_len = 1 };
...@@ -367,7 +367,7 @@ pub const Utf8 = struct {...@@ -367,7 +367,7 @@ pub const Utf8 = struct {
367367
368test "Utf8.WellFormedDecoder" {368test "Utf8.WellFormedDecoder" {
369 const invalid_utf8 = "\xF0\x80";369 const invalid_utf8 = "\xF0\x80";
370 var decoded = Utf8.WellFormedDecoder.decode(invalid_utf8);370 const decoded = Utf8.WellFormedDecoder.decode(invalid_utf8);
371 try std.testing.expectEqual(Codepoint.invalid, decoded.value);371 try std.testing.expectEqual(Codepoint.invalid, decoded.value);
372 try std.testing.expectEqual(@as(usize, 2), decoded.byte_len);372 try std.testing.expectEqual(@as(usize, 2), decoded.byte_len);
373}373}
src/resinator/comments.zig+4-4
...@@ -206,9 +206,9 @@ inline fn handleMultilineCarriageReturn(...@@ -206,9 +206,9 @@ inline fn handleMultilineCarriageReturn(
206}206}
207207
208pub fn removeCommentsAlloc(allocator: Allocator, source: []const u8, source_mappings: ?*SourceMappings) ![]u8 {208pub fn removeCommentsAlloc(allocator: Allocator, source: []const u8, source_mappings: ?*SourceMappings) ![]u8 {
209 var buf = try allocator.alloc(u8, source.len);209 const buf = try allocator.alloc(u8, source.len);
210 errdefer allocator.free(buf);210 errdefer allocator.free(buf);
211 var result = removeComments(source, buf, source_mappings);211 const result = removeComments(source, buf, source_mappings);
212 return allocator.realloc(buf, result.len);212 return allocator.realloc(buf, result.len);
213}213}
214214
...@@ -326,7 +326,7 @@ test "remove comments with mappings" {...@@ -326,7 +326,7 @@ test "remove comments with mappings" {
326 try mappings.set(allocator, 3, .{ .start_line = 3, .end_line = 3, .filename_offset = 0 });326 try mappings.set(allocator, 3, .{ .start_line = 3, .end_line = 3, .filename_offset = 0 });
327 defer mappings.deinit(allocator);327 defer mappings.deinit(allocator);
328328
329 var result = removeComments(&mut_source, &mut_source, &mappings);329 const result = removeComments(&mut_source, &mut_source, &mappings);
330330
331 try std.testing.expectEqualStrings("blahblah", result);331 try std.testing.expectEqualStrings("blahblah", result);
332 try std.testing.expectEqual(@as(usize, 1), mappings.mapping.items.len);332 try std.testing.expectEqual(@as(usize, 1), mappings.mapping.items.len);
...@@ -335,6 +335,6 @@ test "remove comments with mappings" {...@@ -335,6 +335,6 @@ test "remove comments with mappings" {
335335
336test "in place" {336test "in place" {
337 var mut_source = "blah /* comment */ blah".*;337 var mut_source = "blah /* comment */ blah".*;
338 var result = removeComments(&mut_source, &mut_source, null);338 const result = removeComments(&mut_source, &mut_source, null);
339 try std.testing.expectEqualStrings("blah blah", result);339 try std.testing.expectEqualStrings("blah blah", result);
340}340}
src/resinator/compile.zig+4-4
...@@ -666,7 +666,7 @@ pub const Compiler = struct {...@@ -666,7 +666,7 @@ pub const Compiler = struct {
666 },666 },
667 },667 },
668 .dib => {668 .dib => {
669 var bitmap_header: *ico.BitmapHeader = @ptrCast(@alignCast(&header_bytes));669 const bitmap_header: *ico.BitmapHeader = @ptrCast(@alignCast(&header_bytes));
670 if (native_endian == .big) {670 if (native_endian == .big) {
671 std.mem.byteSwapAllFields(ico.BitmapHeader, bitmap_header);671 std.mem.byteSwapAllFields(ico.BitmapHeader, bitmap_header);
672 }672 }
...@@ -1773,13 +1773,13 @@ pub const Compiler = struct {...@@ -1773,13 +1773,13 @@ pub const Compiler = struct {
1773 }1773 }
1774 try data_writer.writeByteNTimes(0, num_padding);1774 try data_writer.writeByteNTimes(0, num_padding);
17751775
1776 var style = if (control.style) |style_expression|1776 const style = if (control.style) |style_expression|
1777 // Certain styles are implied by the control type1777 // Certain styles are implied by the control type
1778 evaluateFlagsExpressionWithDefault(res.ControlClass.getImpliedStyle(control_type), style_expression, self.source, self.input_code_pages)1778 evaluateFlagsExpressionWithDefault(res.ControlClass.getImpliedStyle(control_type), style_expression, self.source, self.input_code_pages)
1779 else1779 else
1780 res.ControlClass.getImpliedStyle(control_type);1780 res.ControlClass.getImpliedStyle(control_type);
17811781
1782 var exstyle = if (control.exstyle) |exstyle_expression|1782 const exstyle = if (control.exstyle) |exstyle_expression|
1783 evaluateFlagsExpressionWithDefault(0, exstyle_expression, self.source, self.input_code_pages)1783 evaluateFlagsExpressionWithDefault(0, exstyle_expression, self.source, self.input_code_pages)
1784 else1784 else
1785 0;1785 0;
...@@ -3205,7 +3205,7 @@ pub const StringTable = struct {...@@ -3205,7 +3205,7 @@ pub const StringTable = struct {
3205 const trimmed_string = trim: {3205 const trimmed_string = trim: {
3206 // Two NUL characters in a row act as a terminator3206 // Two NUL characters in a row act as a terminator
3207 // Note: This is only the case for STRINGTABLE strings3207 // Note: This is only the case for STRINGTABLE strings
3208 var trimmed = trimToDoubleNUL(u16, utf16_string);3208 const trimmed = trimToDoubleNUL(u16, utf16_string);
3209 // We also want to trim any trailing NUL characters3209 // We also want to trim any trailing NUL characters
3210 break :trim std.mem.trimRight(u16, trimmed, &[_]u16{0});3210 break :trim std.mem.trimRight(u16, trimmed, &[_]u16{0});
3211 };3211 };
src/resinator/lang.zig+1-1
...@@ -98,7 +98,7 @@ pub fn tagToId(tag: []const u8) error{InvalidLanguageTag}!?LanguageId {...@@ -98,7 +98,7 @@ pub fn tagToId(tag: []const u8) error{InvalidLanguageTag}!?LanguageId {
98 var normalized_buf: [longest_known_tag]u8 = undefined;98 var normalized_buf: [longest_known_tag]u8 = undefined;
99 // To allow e.g. `de-de_phoneb` to get looked up as `de-de`, we need to99 // To allow e.g. `de-de_phoneb` to get looked up as `de-de`, we need to
100 // omit the suffix, but only if the tag contains a valid alternate sort order.100 // omit the suffix, but only if the tag contains a valid alternate sort order.
101 var tag_to_normalize = if (parsed.isSuffixValidSortOrder()) tag[0 .. tag.len - (parsed.suffix.?.len + 1)] else tag;101 const tag_to_normalize = if (parsed.isSuffixValidSortOrder()) tag[0 .. tag.len - (parsed.suffix.?.len + 1)] else tag;
102 const normalized_tag = normalizeTag(tag_to_normalize, &normalized_buf);102 const normalized_tag = normalizeTag(tag_to_normalize, &normalized_buf);
103 return std.meta.stringToEnum(LanguageId, normalized_tag) orelse {103 return std.meta.stringToEnum(LanguageId, normalized_tag) orelse {
104 // special case for a tag that has been mapped to the same ID104 // special case for a tag that has been mapped to the same ID
src/resinator/parse.zig+6-6
...@@ -100,7 +100,7 @@ pub const Parser = struct {...@@ -100,7 +100,7 @@ pub const Parser = struct {
100 // because it almost always leads to unhelpful error messages100 // because it almost always leads to unhelpful error messages
101 // (usually it will end up with bogus things like 'file101 // (usually it will end up with bogus things like 'file
102 // not found: {')102 // not found: {')
103 var statement = try self.parseStatement();103 const statement = try self.parseStatement();
104 try statements.append(statement);104 try statements.append(statement);
105 }105 }
106 }106 }
...@@ -698,7 +698,7 @@ pub const Parser = struct {...@@ -698,7 +698,7 @@ pub const Parser = struct {
698 .dlginclude => {698 .dlginclude => {
699 const common_resource_attributes = try self.parseCommonResourceAttributes();699 const common_resource_attributes = try self.parseCommonResourceAttributes();
700700
701 var filename_expression = try self.parseExpression(.{701 const filename_expression = try self.parseExpression(.{
702 .allowed_types = .{ .string = true },702 .allowed_types = .{ .string = true },
703 });703 });
704704
...@@ -756,7 +756,7 @@ pub const Parser = struct {...@@ -756,7 +756,7 @@ pub const Parser = struct {
756 return &node.base;756 return &node.base;
757 }757 }
758758
759 var filename_expression = try self.parseExpression(.{759 const filename_expression = try self.parseExpression(.{
760 // Don't tell the user that numbers are accepted since we error on760 // Don't tell the user that numbers are accepted since we error on
761 // number expressions and regular number literals are treated as unquoted761 // number expressions and regular number literals are treated as unquoted
762 // literals rather than numbers, so from the users perspective762 // literals rather than numbers, so from the users perspective
...@@ -934,8 +934,8 @@ pub const Parser = struct {...@@ -934,8 +934,8 @@ pub const Parser = struct {
934 style = try optional_param_parser.parse(.{ .not_expression_allowed = true });934 style = try optional_param_parser.parse(.{ .not_expression_allowed = true });
935 }935 }
936936
937 var exstyle: ?*Node = try optional_param_parser.parse(.{ .not_expression_allowed = true });937 const exstyle: ?*Node = try optional_param_parser.parse(.{ .not_expression_allowed = true });
938 var help_id: ?*Node = switch (resource) {938 const help_id: ?*Node = switch (resource) {
939 .dialogex => try optional_param_parser.parse(.{}),939 .dialogex => try optional_param_parser.parse(.{}),
940 else => null,940 else => null,
941 };941 };
...@@ -1526,7 +1526,7 @@ pub const Parser = struct {...@@ -1526,7 +1526,7 @@ pub const Parser = struct {
15261526
1527 pub fn toErrorDetails(options: ParseExpressionOptions, token: Token) ErrorDetails {1527 pub fn toErrorDetails(options: ParseExpressionOptions, token: Token) ErrorDetails {
1528 // TODO: expected_types_override interaction with is_known_to_be_number_expression?1528 // TODO: expected_types_override interaction with is_known_to_be_number_expression?
1529 var expected_types = options.expected_types_override orelse ErrorDetails.ExpectedTypes{1529 const expected_types = options.expected_types_override orelse ErrorDetails.ExpectedTypes{
1530 .number = options.allowed_types.number,1530 .number = options.allowed_types.number,
1531 .number_expression = options.allowed_types.number,1531 .number_expression = options.allowed_types.number,
1532 .string_literal = options.allowed_types.string and !options.is_known_to_be_number_expression,1532 .string_literal = options.allowed_types.string and !options.is_known_to_be_number_expression,
src/resinator/res.zig+2-2
...@@ -357,7 +357,7 @@ pub const NameOrOrdinal = union(enum) {...@@ -357,7 +357,7 @@ pub const NameOrOrdinal = union(enum) {
357 /// RC compiler would have allowed them, so that a proper warning/error357 /// RC compiler would have allowed them, so that a proper warning/error
358 /// can be emitted.358 /// can be emitted.
359 pub fn maybeNonAsciiOrdinalFromString(bytes: SourceBytes) ?NameOrOrdinal {359 pub fn maybeNonAsciiOrdinalFromString(bytes: SourceBytes) ?NameOrOrdinal {
360 var buf = bytes.slice;360 const buf = bytes.slice;
361 const radix = 10;361 const radix = 10;
362 if (buf.len > 2 and buf[0] == '0') {362 if (buf.len > 2 and buf[0] == '0') {
363 switch (buf[1]) {363 switch (buf[1]) {
...@@ -514,7 +514,7 @@ test "NameOrOrdinal" {...@@ -514,7 +514,7 @@ test "NameOrOrdinal" {
514 {514 {
515 var expected = blk: {515 var expected = blk: {
516 // the input before the 𐐷 character, but uppercased516 // the input before the 𐐷 character, but uppercased
517 var expected_u8_bytes = "00614982008907933748980730280674788429543776231864944218790698304852300002973622122844631429099469274282385299397783838528QFFL7SHNSIETG0QKLR1UYPBTUV1PMFQRRA0VJDG354GQEDJMUPGPP1W1EXVNTZVEIZ6K3IPQM1AWGEYALMEODYVEZGOD3MFMGEY8FNR4JUETTB1PZDEWSNDRGZUA8SNXP3NGO";517 const expected_u8_bytes = "00614982008907933748980730280674788429543776231864944218790698304852300002973622122844631429099469274282385299397783838528QFFL7SHNSIETG0QKLR1UYPBTUV1PMFQRRA0VJDG354GQEDJMUPGPP1W1EXVNTZVEIZ6K3IPQM1AWGEYALMEODYVEZGOD3MFMGEY8FNR4JUETTB1PZDEWSNDRGZUA8SNXP3NGO";
518 var buf: [256:0]u16 = undefined;518 var buf: [256:0]u16 = undefined;
519 for (expected_u8_bytes, 0..) |byte, i| {519 for (expected_u8_bytes, 0..) |byte, i| {
520 buf[i] = std.mem.nativeToLittle(u16, byte);520 buf[i] = std.mem.nativeToLittle(u16, byte);
src/resinator/source_mapping.zig+2-2
...@@ -251,7 +251,7 @@ pub fn handleLineCommand(allocator: Allocator, line_command: []const u8, current...@@ -251,7 +251,7 @@ pub fn handleLineCommand(allocator: Allocator, line_command: []const u8, current
251}251}
252252
253pub fn parseAndRemoveLineCommandsAlloc(allocator: Allocator, source: []const u8, options: ParseAndRemoveLineCommandsOptions) !ParseLineCommandsResult {253pub fn parseAndRemoveLineCommandsAlloc(allocator: Allocator, source: []const u8, options: ParseAndRemoveLineCommandsOptions) !ParseLineCommandsResult {
254 var buf = try allocator.alloc(u8, source.len);254 const buf = try allocator.alloc(u8, source.len);
255 errdefer allocator.free(buf);255 errdefer allocator.free(buf);
256 var result = try parseAndRemoveLineCommands(allocator, source, buf, options);256 var result = try parseAndRemoveLineCommands(allocator, source, buf, options);
257 result.result = try allocator.realloc(buf, result.result.len);257 result.result = try allocator.realloc(buf, result.result.len);
...@@ -440,7 +440,7 @@ pub const SourceMappings = struct {...@@ -440,7 +440,7 @@ pub const SourceMappings = struct {
440 }440 }
441441
442 pub fn set(self: *SourceMappings, allocator: Allocator, line_num: usize, span: SourceSpan) !void {442 pub fn set(self: *SourceMappings, allocator: Allocator, line_num: usize, span: SourceSpan) !void {
443 var ptr = try self.expandAndGet(allocator, line_num);443 const ptr = try self.expandAndGet(allocator, line_num);
444 ptr.* = span;444 ptr.* = span;
445 }445 }
446446
src/translate_c.zig+5-5
...@@ -456,7 +456,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void {...@@ -456,7 +456,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void {
456 block_scope.return_type = return_qt;456 block_scope.return_type = return_qt;
457 defer block_scope.deinit();457 defer block_scope.deinit();
458458
459 var scope = &block_scope.base;459 const scope = &block_scope.base;
460460
461 var param_id: c_uint = 0;461 var param_id: c_uint = 0;
462 for (proto_node.data.params) |*param| {462 for (proto_node.data.params) |*param| {
...@@ -1363,7 +1363,7 @@ fn transSimpleOffsetOfExpr(c: *Context, expr: *const clang.OffsetOfExpr) TransEr...@@ -1363,7 +1363,7 @@ fn transSimpleOffsetOfExpr(c: *Context, expr: *const clang.OffsetOfExpr) TransEr
1363 if (c.decl_table.get(@intFromPtr(record_decl.getCanonicalDecl()))) |type_name| {1363 if (c.decl_table.get(@intFromPtr(record_decl.getCanonicalDecl()))) |type_name| {
1364 const type_node = try Tag.type.create(c.arena, type_name);1364 const type_node = try Tag.type.create(c.arena, type_name);
13651365
1366 var raw_field_name = try c.str(@as(*const clang.NamedDecl, @ptrCast(field_decl)).getName_bytes_begin());1366 const raw_field_name = try c.str(@as(*const clang.NamedDecl, @ptrCast(field_decl)).getName_bytes_begin());
1367 const quoted_field_name = try std.fmt.allocPrint(c.arena, "\"{s}\"", .{raw_field_name});1367 const quoted_field_name = try std.fmt.allocPrint(c.arena, "\"{s}\"", .{raw_field_name});
1368 const field_name_node = try Tag.string_literal.create(c.arena, quoted_field_name);1368 const field_name_node = try Tag.string_literal.create(c.arena, quoted_field_name);
13691369
...@@ -1967,7 +1967,7 @@ fn transBoolExpr(...@@ -1967,7 +1967,7 @@ fn transBoolExpr(
1967 return Node{ .tag_if_small_enough = @intFromEnum(([2]Tag{ .true_literal, .false_literal })[@intFromBool(is_zero)]) };1967 return Node{ .tag_if_small_enough = @intFromEnum(([2]Tag{ .true_literal, .false_literal })[@intFromBool(is_zero)]) };
1968 }1968 }
19691969
1970 var res = try transExpr(c, scope, expr, used);1970 const res = try transExpr(c, scope, expr, used);
1971 if (isBoolRes(res)) {1971 if (isBoolRes(res)) {
1972 return maybeSuppressResult(c, used, res);1972 return maybeSuppressResult(c, used, res);
1973 }1973 }
...@@ -3477,7 +3477,7 @@ fn cIsFunctionDeclRef(expr: *const clang.Expr) bool {...@@ -3477,7 +3477,7 @@ fn cIsFunctionDeclRef(expr: *const clang.Expr) bool {
34773477
3478fn transCallExpr(c: *Context, scope: *Scope, stmt: *const clang.CallExpr, result_used: ResultUsed) TransError!Node {3478fn transCallExpr(c: *Context, scope: *Scope, stmt: *const clang.CallExpr, result_used: ResultUsed) TransError!Node {
3479 const callee = stmt.getCallee();3479 const callee = stmt.getCallee();
3480 var raw_fn_expr = try transExpr(c, scope, callee, .used);3480 const raw_fn_expr = try transExpr(c, scope, callee, .used);
34813481
3482 var is_ptr = false;3482 var is_ptr = false;
3483 const fn_ty = qualTypeGetFnProto(callee.getType(), &is_ptr);3483 const fn_ty = qualTypeGetFnProto(callee.getType(), &is_ptr);
...@@ -5889,7 +5889,7 @@ fn escapeUnprintables(ctx: *Context, m: *MacroCtx) ![]const u8 {...@@ -5889,7 +5889,7 @@ fn escapeUnprintables(ctx: *Context, m: *MacroCtx) ![]const u8 {
58895889
5890 const formatter = std.fmt.fmtSliceEscapeLower(zigified);5890 const formatter = std.fmt.fmtSliceEscapeLower(zigified);
5891 const encoded_size = @as(usize, @intCast(std.fmt.count("{s}", .{formatter})));5891 const encoded_size = @as(usize, @intCast(std.fmt.count("{s}", .{formatter})));
5892 var output = try ctx.arena.alloc(u8, encoded_size);5892 const output = try ctx.arena.alloc(u8, encoded_size);
5893 return std.fmt.bufPrint(output, "{s}", .{formatter}) catch |err| switch (err) {5893 return std.fmt.bufPrint(output, "{s}", .{formatter}) catch |err| switch (err) {
5894 error.NoSpaceLeft => unreachable,5894 error.NoSpaceLeft => unreachable,
5895 else => |e| return e,5895 else => |e| return e,
src/value.zig+3-3
...@@ -2136,7 +2136,7 @@ pub const Value = struct {...@@ -2136,7 +2136,7 @@ pub const Value = struct {
2136 lhs_bigint.limbs.len + rhs_bigint.limbs.len,2136 lhs_bigint.limbs.len + rhs_bigint.limbs.len,
2137 );2137 );
2138 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };2138 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };
2139 var limbs_buffer = try arena.alloc(2139 const limbs_buffer = try arena.alloc(
2140 std.math.big.Limb,2140 std.math.big.Limb,
2141 std.math.big.int.calcMulLimbsBufferLen(lhs_bigint.limbs.len, rhs_bigint.limbs.len, 1),2141 std.math.big.int.calcMulLimbsBufferLen(lhs_bigint.limbs.len, rhs_bigint.limbs.len, 1),
2142 );2142 );
...@@ -2249,7 +2249,7 @@ pub const Value = struct {...@@ -2249,7 +2249,7 @@ pub const Value = struct {
2249 ),2249 ),
2250 );2250 );
2251 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };2251 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };
2252 var limbs_buffer = try arena.alloc(2252 const limbs_buffer = try arena.alloc(
2253 std.math.big.Limb,2253 std.math.big.Limb,
2254 std.math.big.int.calcMulLimbsBufferLen(lhs_bigint.limbs.len, rhs_bigint.limbs.len, 1),2254 std.math.big.int.calcMulLimbsBufferLen(lhs_bigint.limbs.len, rhs_bigint.limbs.len, 1),
2255 );2255 );
...@@ -2788,7 +2788,7 @@ pub const Value = struct {...@@ -2788,7 +2788,7 @@ pub const Value = struct {
2788 lhs_bigint.limbs.len + rhs_bigint.limbs.len,2788 lhs_bigint.limbs.len + rhs_bigint.limbs.len,
2789 );2789 );
2790 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };2790 var result_bigint = BigIntMutable{ .limbs = limbs, .positive = undefined, .len = undefined };
2791 var limbs_buffer = try allocator.alloc(2791 const limbs_buffer = try allocator.alloc(
2792 std.math.big.Limb,2792 std.math.big.Limb,
2793 std.math.big.int.calcMulLimbsBufferLen(lhs_bigint.limbs.len, rhs_bigint.limbs.len, 1),2793 std.math.big.int.calcMulLimbsBufferLen(lhs_bigint.limbs.len, rhs_bigint.limbs.len, 1),
2794 );2794 );
src/windows_sdk.zig+9-9
...@@ -69,7 +69,7 @@ fn iterateAndFilterBySemVer(iterator: *std.fs.IterableDir.Iterator, allocator: s...@@ -69,7 +69,7 @@ fn iterateAndFilterBySemVer(iterator: *std.fs.IterableDir.Iterator, allocator: s
69 try dirs_filtered_list.append(subfolder_name_allocated);69 try dirs_filtered_list.append(subfolder_name_allocated);
70 }70 }
7171
72 var dirs_filtered_slice = try dirs_filtered_list.toOwnedSlice();72 const dirs_filtered_slice = try dirs_filtered_list.toOwnedSlice();
73 // Keep in mind that order of these names is not guaranteed by Windows,73 // Keep in mind that order of these names is not guaranteed by Windows,
74 // so we cannot just reverse or "while (popOrNull())" this ArrayList.74 // so we cannot just reverse or "while (popOrNull())" this ArrayList.
75 std.mem.sortUnstable([]const u8, dirs_filtered_slice, {}, struct {75 std.mem.sortUnstable([]const u8, dirs_filtered_slice, {}, struct {
...@@ -129,7 +129,7 @@ const RegistryUtf8 = struct {...@@ -129,7 +129,7 @@ const RegistryUtf8 = struct {
129 const value_utf16le = try registry_utf16le.getString(allocator, subkey_utf16le, value_name_utf16le);129 const value_utf16le = try registry_utf16le.getString(allocator, subkey_utf16le, value_name_utf16le);
130 defer allocator.free(value_utf16le);130 defer allocator.free(value_utf16le);
131131
132 var value_utf8: []u8 = std.unicode.utf16leToUtf8Alloc(allocator, value_utf16le) catch |err| switch (err) {132 const value_utf8: []u8 = std.unicode.utf16leToUtf8Alloc(allocator, value_utf16le) catch |err| switch (err) {
133 error.OutOfMemory => return error.OutOfMemory,133 error.OutOfMemory => return error.OutOfMemory,
134 else => return error.StringNotFound,134 else => return error.StringNotFound,
135 };135 };
...@@ -246,7 +246,7 @@ const RegistryUtf16Le = struct {...@@ -246,7 +246,7 @@ const RegistryUtf16Le = struct {
246 else => return error.NotAString,246 else => return error.NotAString,
247 }247 }
248248
249 var value_utf16le_buf: []u16 = try allocator.alloc(u16, std.math.divCeil(u32, value_utf16le_buf_size, 2) catch unreachable);249 const value_utf16le_buf: []u16 = try allocator.alloc(u16, std.math.divCeil(u32, value_utf16le_buf_size, 2) catch unreachable);
250 errdefer allocator.free(value_utf16le_buf);250 errdefer allocator.free(value_utf16le_buf);
251251
252 return_code_int = windows.advapi32.RegGetValueW(252 return_code_int = windows.advapi32.RegGetValueW(
...@@ -354,7 +354,7 @@ pub const Windows10Sdk = struct {...@@ -354,7 +354,7 @@ pub const Windows10Sdk = struct {
354 defer v10_key.closeKey();354 defer v10_key.closeKey();
355355
356 const path: []const u8 = path10: {356 const path: []const u8 = path10: {
357 var path_maybe_with_trailing_slash = v10_key.getString(allocator, "", "InstallationFolder") catch |err| switch (err) {357 const path_maybe_with_trailing_slash = v10_key.getString(allocator, "", "InstallationFolder") catch |err| switch (err) {
358 error.NotAString => return error.Windows10SdkNotFound,358 error.NotAString => return error.Windows10SdkNotFound,
359 error.ValueNameNotFound => return error.Windows10SdkNotFound,359 error.ValueNameNotFound => return error.Windows10SdkNotFound,
360 error.StringNotFound => return error.Windows10SdkNotFound,360 error.StringNotFound => return error.Windows10SdkNotFound,
...@@ -381,7 +381,7 @@ pub const Windows10Sdk = struct {...@@ -381,7 +381,7 @@ pub const Windows10Sdk = struct {
381 const version: []const u8 = version10: {381 const version: []const u8 = version10: {
382382
383 // note(dimenus): Microsoft doesn't include the .0 in the ProductVersion key....383 // note(dimenus): Microsoft doesn't include the .0 in the ProductVersion key....
384 var version_without_0 = v10_key.getString(allocator, "", "ProductVersion") catch |err| switch (err) {384 const version_without_0 = v10_key.getString(allocator, "", "ProductVersion") catch |err| switch (err) {
385 error.NotAString => return error.Windows10SdkNotFound,385 error.NotAString => return error.Windows10SdkNotFound,
386 error.ValueNameNotFound => return error.Windows10SdkNotFound,386 error.ValueNameNotFound => return error.Windows10SdkNotFound,
387 error.StringNotFound => return error.Windows10SdkNotFound,387 error.StringNotFound => return error.Windows10SdkNotFound,
...@@ -445,7 +445,7 @@ pub const Windows81Sdk = struct {...@@ -445,7 +445,7 @@ pub const Windows81Sdk = struct {
445 /// After finishing work, call `free(allocator)`.445 /// After finishing work, call `free(allocator)`.
446 fn find(allocator: std.mem.Allocator, roots_key: *const RegistryUtf8) error{ OutOfMemory, Windows81SdkNotFound, PathTooLong, VersionTooLong }!Windows81Sdk {446 fn find(allocator: std.mem.Allocator, roots_key: *const RegistryUtf8) error{ OutOfMemory, Windows81SdkNotFound, PathTooLong, VersionTooLong }!Windows81Sdk {
447 const path: []const u8 = path81: {447 const path: []const u8 = path81: {
448 var path_maybe_with_trailing_slash = roots_key.getString(allocator, "", "KitsRoot81") catch |err| switch (err) {448 const path_maybe_with_trailing_slash = roots_key.getString(allocator, "", "KitsRoot81") catch |err| switch (err) {
449 error.NotAString => return error.Windows81SdkNotFound,449 error.NotAString => return error.Windows81SdkNotFound,
450 error.ValueNameNotFound => return error.Windows81SdkNotFound,450 error.ValueNameNotFound => return error.Windows81SdkNotFound,
451 error.StringNotFound => return error.Windows81SdkNotFound,451 error.StringNotFound => return error.Windows81SdkNotFound,
...@@ -752,7 +752,7 @@ const MsvcLibDir = struct {...@@ -752,7 +752,7 @@ const MsvcLibDir = struct {
752752
753 const config_subkey = std.fmt.bufPrint(config_subkey_buf[0..], "Software\\Microsoft\\VisualStudio\\{s}_Config", .{vs_version}) catch unreachable;753 const config_subkey = std.fmt.bufPrint(config_subkey_buf[0..], "Software\\Microsoft\\VisualStudio\\{s}_Config", .{vs_version}) catch unreachable;
754754
755 var source_directories_value = visualstudio_registry.getString(allocator, config_subkey, "Source Directories") catch |err| switch (err) {755 const source_directories_value = visualstudio_registry.getString(allocator, config_subkey, "Source Directories") catch |err| switch (err) {
756 error.OutOfMemory => return error.OutOfMemory,756 error.OutOfMemory => return error.OutOfMemory,
757 else => continue,757 else => continue,
758 };758 };
...@@ -768,7 +768,7 @@ const MsvcLibDir = struct {...@@ -768,7 +768,7 @@ const MsvcLibDir = struct {
768 var source_directories_splitted = std.mem.splitScalar(u8, source_directories, ';');768 var source_directories_splitted = std.mem.splitScalar(u8, source_directories, ';');
769769
770 const msvc_dir: []const u8 = msvc_dir: {770 const msvc_dir: []const u8 = msvc_dir: {
771 var msvc_include_dir_maybe_with_trailing_slash = try allocator.dupe(u8, source_directories_splitted.first());771 const msvc_include_dir_maybe_with_trailing_slash = try allocator.dupe(u8, source_directories_splitted.first());
772772
773 if (msvc_include_dir_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(msvc_include_dir_maybe_with_trailing_slash)) {773 if (msvc_include_dir_maybe_with_trailing_slash.len > std.fs.MAX_PATH_BYTES or !std.fs.path.isAbsolute(msvc_include_dir_maybe_with_trailing_slash)) {
774 allocator.free(msvc_include_dir_maybe_with_trailing_slash);774 allocator.free(msvc_include_dir_maybe_with_trailing_slash);
...@@ -833,7 +833,7 @@ const MsvcLibDir = struct {...@@ -833,7 +833,7 @@ const MsvcLibDir = struct {
833 const vs7_key = RegistryUtf8.openKey("SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7") catch return error.PathNotFound;833 const vs7_key = RegistryUtf8.openKey("SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7") catch return error.PathNotFound;
834 defer vs7_key.closeKey();834 defer vs7_key.closeKey();
835 try_vs7_key: {835 try_vs7_key: {
836 var path_maybe_with_trailing_slash = vs7_key.getString(allocator, "", "14.0") catch |err| switch (err) {836 const path_maybe_with_trailing_slash = vs7_key.getString(allocator, "", "14.0") catch |err| switch (err) {
837 error.OutOfMemory => return error.OutOfMemory,837 error.OutOfMemory => return error.OutOfMemory,
838 else => break :try_vs7_key,838 else => break :try_vs7_key,
839 };839 };