aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-02-18 09:02:57 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-02-18 19:17:21 -0700
commitaeaef8c0ffadab4145fd002f2edd87a6db66ebd1 (patch)
treee4c76c76173e5e72bc1947e1886662c4c6b2ba3c /tools
parentf0530385b57218ef323747bdb7438330a07d25cc (diff)
downloadzig-aeaef8c0ffadab4145fd002f2edd87a6db66ebd1.tar.gz
zig-aeaef8c0ffadab4145fd002f2edd87a6db66ebd1.zip
update std lib and compiler sources to new for loop syntax
Diffstat (limited to 'tools')
-rw-r--r--tools/gen_spirv_spec.zig18
-rw-r--r--tools/gen_stubs.zig18
-rw-r--r--tools/update_clang_options.zig2
-rw-r--r--tools/update_cpu_features.zig4
-rw-r--r--tools/update_crc_catalog.zig2
-rw-r--r--tools/update_spirv_features.zig4
6 files changed, 24 insertions, 24 deletions
diff --git a/tools/gen_spirv_spec.zig b/tools/gen_spirv_spec.zig
index 426276122c..31dbbb1911 100644
--- a/tools/gen_spirv_spec.zig
+++ b/tools/gen_spirv_spec.zig
@@ -251,7 +251,7 @@ fn renderEnumerant(writer: anytype, enumerant: g.Enumerant) !void {
.int => |int| try writer.print("{}", .{int}),
}
try writer.writeAll(", .parameters = &[_]OperandKind{");
- for (enumerant.parameters) |param, i| {
+ for (enumerant.parameters, 0..) |param, i| {
if (i != 0)
try writer.writeAll(", ");
// Note, param.quantifier will always be one.
@@ -272,7 +272,7 @@ fn renderOpcodes(
var aliases = std.ArrayList(struct { inst: usize, alias: usize }).init(allocator);
try aliases.ensureTotalCapacity(instructions.len);
- for (instructions) |inst, i| {
+ for (instructions, 0..) |inst, i| {
if (std.mem.eql(u8, inst.class.?, "@exclude")) {
continue;
}
@@ -397,7 +397,7 @@ fn renderValueEnum(
var aliases = std.ArrayList(struct { enumerant: usize, alias: usize }).init(allocator);
try aliases.ensureTotalCapacity(enumerants.len);
- for (enumerants) |enumerant, i| {
+ for (enumerants, 0..) |enumerant, i| {
const result = enum_map.getOrPutAssumeCapacity(enumerant.value.int);
if (!result.found_existing) {
result.value_ptr.* = i;
@@ -468,7 +468,7 @@ fn renderBitEnum(
var aliases = std.ArrayList(struct { flag: usize, alias: u5 }).init(allocator);
try aliases.ensureTotalCapacity(enumerants.len);
- for (enumerants) |enumerant, i| {
+ for (enumerants, 0..) |enumerant, i| {
if (enumerant.value != .bitflag) return error.InvalidRegistry;
const value = try parseHexInt(enumerant.value.bitflag);
if (value == 0) {
@@ -494,7 +494,7 @@ fn renderBitEnum(
}
}
- for (flags_by_bitpos) |maybe_flag_index, bitpos| {
+ for (flags_by_bitpos, 0..) |maybe_flag_index, bitpos| {
if (maybe_flag_index) |flag_index| {
try writer.print("{}", .{std.zig.fmtId(enumerants[flag_index].enumerant)});
} else {
@@ -521,7 +521,7 @@ fn renderBitEnum(
try writer.print("\npub const Extended = struct {{\n", .{});
- for (flags_by_bitpos) |maybe_flag_index, bitpos| {
+ for (flags_by_bitpos, 0..) |maybe_flag_index, bitpos| {
const flag_index = maybe_flag_index orelse {
try writer.print("_reserved_bit_{}: bool = false,\n", .{bitpos});
continue;
@@ -570,7 +570,7 @@ fn renderOperand(
try writer.writeAll("struct{");
- for (parameters) |param, j| {
+ for (parameters, 0..) |param, j| {
if (j != 0) {
try writer.writeAll(", ");
}
@@ -642,7 +642,7 @@ fn renderFieldName(writer: anytype, operands: []const g.Operand, field_index: us
// Translate to snake case.
name_buffer.len = 0;
- for (operand.kind) |c, i| {
+ for (operand.kind, 0..) |c, i| {
switch (c) {
'a'...'z', '0'...'9' => try name_buffer.append(c),
'A'...'Z' => if (i > 0 and std.ascii.isLower(operand.kind[i - 1])) {
@@ -658,7 +658,7 @@ fn renderFieldName(writer: anytype, operands: []const g.Operand, field_index: us
// For fields derived from type name, there could be any amount.
// Simply check against all other fields, and if another similar one exists, add a number.
- const need_extra_index = for (operands) |other_operand, i| {
+ const need_extra_index = for (operands, 0..) |other_operand, i| {
if (i != field_index and std.mem.eql(u8, operand.kind, other_operand.kind)) {
break true;
}
diff --git a/tools/gen_stubs.zig b/tools/gen_stubs.zig
index 89d7a40228..bc2637e197 100644
--- a/tools/gen_stubs.zig
+++ b/tools/gen_stubs.zig
@@ -45,7 +45,7 @@ const MultiSym = struct {
visib: elf.STV,
fn allPresent(ms: MultiSym) bool {
- for (arches) |_, i| {
+ for (arches, 0..) |_, i| {
if (!ms.present[i]) {
return false;
}
@@ -65,7 +65,7 @@ const MultiSym = struct {
fn commonSize(ms: MultiSym) ?u64 {
var size: ?u64 = null;
- for (arches) |_, i| {
+ for (arches, 0..) |_, i| {
if (!ms.present[i]) continue;
if (size) |s| {
if (ms.size[i] != s) {
@@ -80,7 +80,7 @@ const MultiSym = struct {
fn commonBinding(ms: MultiSym) ?u4 {
var binding: ?u4 = null;
- for (arches) |_, i| {
+ for (arches, 0..) |_, i| {
if (!ms.present[i]) continue;
if (binding) |b| {
if (ms.binding[i] != b) {
@@ -268,7 +268,7 @@ pub fn main() !void {
var prev_section: u16 = std.math.maxInt(u16);
var prev_pp_state: enum { none, ptr32, special } = .none;
- for (sym_table.values()) |multi_sym, sym_index| {
+ for (sym_table.values(), 0..) |multi_sym, sym_index| {
const name = sym_table.keys()[sym_index];
if (multi_sym.section != prev_section) {
@@ -309,7 +309,7 @@ pub fn main() !void {
var first = true;
try stdout.writeAll("#if ");
- for (arches) |arch, i| {
+ for (arches, 0..) |arch, i| {
if (multi_sym.present[i]) continue;
if (!first) try stdout.writeAll(" && ");
@@ -333,7 +333,7 @@ pub fn main() !void {
} else if (multi_sym.isWeak64()) {
try stdout.print("WEAK64 {s}\n", .{name});
} else {
- for (arches) |arch, i| {
+ for (arches, 0..) |arch, i| {
log.info("symbol '{s}' binding on {s}: {d}", .{
name, @tagName(arch), multi_sym.binding[i],
});
@@ -355,7 +355,7 @@ pub fn main() !void {
} else if (multi_sym.isPtr2Size()) {
try stdout.print(".size {s}, PTR2_SIZE_BYTES\n", .{name});
} else {
- for (arches) |arch, i| {
+ for (arches, 0..) |arch, i| {
log.info("symbol '{s}' size on {s}: {d}", .{
name, @tagName(arch), multi_sym.size[i],
});
@@ -415,7 +415,7 @@ fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian)
// Find the offset of the dynamic symbol table.
var dynsym_index: u16 = 0;
- for (shdrs) |shdr, i| {
+ for (shdrs, 0..) |shdr, i| {
const sh_name = try arena.dupe(u8, mem.sliceTo(shstrtab[s(shdr.sh_name)..], 0));
log.debug("found section: {s}", .{sh_name});
if (mem.eql(u8, sh_name, ".dynsym")) {
@@ -566,7 +566,7 @@ fn archIndex(arch: std.Target.Cpu.Arch) u8 {
}
fn archSetName(arch_set: [arches.len]bool) []const u8 {
- for (arches) |arch, i| {
+ for (arches, 0..) |arch, i| {
if (arch_set[i]) {
return @tagName(arch);
}
diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig
index 85558576df..a1719c5ab6 100644
--- a/tools/update_clang_options.zig
+++ b/tools/update_clang_options.zig
@@ -573,7 +573,7 @@ pub fn main() anyerror!void {
const Feature = @field(cpu_targets, decl.name).Feature;
const all_features = @field(cpu_targets, decl.name).all_features;
- for (all_features) |feat, i| {
+ for (all_features, 0..) |feat, i| {
const llvm_name = feat.llvm_name orelse continue;
const zig_feat = @intToEnum(Feature, i);
const zig_name = @tagName(zig_feat);
diff --git a/tools/update_cpu_features.zig b/tools/update_cpu_features.zig
index ee92d63227..3fef468380 100644
--- a/tools/update_cpu_features.zig
+++ b/tools/update_cpu_features.zig
@@ -899,7 +899,7 @@ pub fn main() anyerror!void {
}
} else {
var threads = try arena.alloc(std.Thread, llvm_targets.len);
- for (llvm_targets) |llvm_target, i| {
+ for (llvm_targets, 0..) |llvm_target, i| {
const job = Job{
.llvm_tblgen_exe = llvm_tblgen_exe,
.llvm_src_root = llvm_src_root,
@@ -1226,7 +1226,7 @@ fn processOneTarget(job: Job) anyerror!void {
}
try w.writeAll(
\\ const ti = @typeInfo(Feature);
- \\ for (result) |*elem, i| {
+ \\ for (&result, 0..) |*elem, i| {
\\ elem.index = i;
\\ elem.name = ti.Enum.fields[i].name;
\\ }
diff --git a/tools/update_crc_catalog.zig b/tools/update_crc_catalog.zig
index 8182e8d810..034b7afc9d 100644
--- a/tools/update_crc_catalog.zig
+++ b/tools/update_crc_catalog.zig
@@ -116,7 +116,7 @@ pub fn main() anyerror!void {
defer buf.deinit();
var prev: u8 = 0;
- for (snakecase) |c, i| {
+ for (snakecase, 0..) |c, i| {
if (c == '_') {
// do nothing
} else if (i == 0) {
diff --git a/tools/update_spirv_features.zig b/tools/update_spirv_features.zig
index a7eb3c18f9..bb859ed5b4 100644
--- a/tools/update_spirv_features.zig
+++ b/tools/update_spirv_features.zig
@@ -130,7 +130,7 @@ pub fn main() !void {
\\
);
- for (versions) |ver, i| {
+ for (versions, 0..) |ver, i| {
try w.print(
\\ result[@enumToInt(Feature.v{0}_{1})] = .{{
\\ .llvm_name = null,
@@ -203,7 +203,7 @@ pub fn main() !void {
try w.writeAll(
\\ const ti = @typeInfo(Feature);
- \\ for (result) |*elem, i| {
+ \\ for (&result, 0..) |*elem, i| {
\\ elem.index = i;
\\ elem.name = ti.Enum.fields[i].name;
\\ }