zig build fmt

This commit is contained in:
Andrew Kelley 2025-02-22 17:03:24 -08:00
parent c0c911bfa7
commit eb3c7f5706
40 changed files with 1242 additions and 1246 deletions

View file

@ -979,7 +979,7 @@ fn decl(p: *Parser) Error!bool {
_ = try p.expectToken(.semicolon);
if (decl_spec.ty.is(.@"enum") or
(decl_spec.ty.isRecord() and !decl_spec.ty.isAnonymousRecord(p.comp) and
!decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
!decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
{
const specifier = decl_spec.ty.canonicalize(.standard).specifier;
const attrs = p.attr_buf.items(.attr)[attr_buf_top..];

View file

@ -114,9 +114,9 @@ fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex
const gcc_pragma = std.meta.stringToEnum(Directive, pp.expandedSlice(directive_tok)) orelse
return pp.comp.addDiagnostic(.{
.tag = .unknown_gcc_pragma,
.loc = directive_tok.loc,
}, pp.expansionSlice(start_idx + 1));
.tag = .unknown_gcc_pragma,
.loc = directive_tok.loc,
}, pp.expansionSlice(start_idx + 1));
switch (gcc_pragma) {
.warning, .@"error" => {

View file

@ -255,7 +255,7 @@ pub fn parse(lang_tag: []const u8) error{InvalidLanguageTag}!Parsed {
// Special case for qps-ploca and qps-plocm
else if (std.ascii.eqlIgnoreCase(lang_code, "qps") and
(std.ascii.eqlIgnoreCase(part_str, "ploca") or
std.ascii.eqlIgnoreCase(part_str, "plocm")))
std.ascii.eqlIgnoreCase(part_str, "plocm")))
{
parsed.suffix = part_str;
} else {

View file

@ -143,7 +143,7 @@ pub const __clzsi2 = switch (builtin.cpu.arch) {
.arm, .armeb, .thumb, .thumbeb => impl: {
const use_thumb1 =
(builtin.cpu.arch.isThumb() or
std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
!std.Target.arm.featureSetHas(builtin.cpu.features, .thumb2);
if (use_thumb1) {

View file

@ -81,19 +81,19 @@ fn test_one_divmoddi4(a: i64, b: i64, expected_q: i64, expected_r: i64) !void {
const cases__divmoddi4 =
[_][4]i64{
[_]i64{ 0, 1, 0, 0 },
[_]i64{ 0, -1, 0, 0 },
[_]i64{ 2, 1, 2, 0 },
[_]i64{ 2, -1, -2, 0 },
[_]i64{ -2, 1, -2, 0 },
[_]i64{ -2, -1, 2, 0 },
[_]i64{ 7, 5, 1, 2 },
[_]i64{ -7, 5, -1, -2 },
[_]i64{ 19, 5, 3, 4 },
[_]i64{ 19, -5, -3, 4 },
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000000))), 0 },
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000007))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000001))), -1 },
};
[_]i64{ 0, 1, 0, 0 },
[_]i64{ 0, -1, 0, 0 },
[_]i64{ 2, 1, 2, 0 },
[_]i64{ 2, -1, -2, 0 },
[_]i64{ -2, 1, -2, 0 },
[_]i64{ -2, -1, 2, 0 },
[_]i64{ 7, 5, 1, 2 },
[_]i64{ -7, 5, -1, -2 },
[_]i64{ 19, 5, 3, 4 },
[_]i64{ 19, -5, -3, 4 },
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000000))), 0 },
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000007))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000001))), -1 },
};
test "test_divmoddi4" {
for (cases__divmoddi4) |case| {
@ -215,19 +215,19 @@ pub fn __divmodsi4(a: i32, b: i32, rem: *i32) callconv(.C) i32 {
const cases__divmodsi4 =
[_][4]i32{
[_]i32{ 0, 1, 0, 0 },
[_]i32{ 0, -1, 0, 0 },
[_]i32{ 2, 1, 2, 0 },
[_]i32{ 2, -1, -2, 0 },
[_]i32{ -2, 1, -2, 0 },
[_]i32{ -2, -1, 2, 0 },
[_]i32{ 7, 5, 1, 2 },
[_]i32{ -7, 5, -1, -2 },
[_]i32{ 19, 5, 3, 4 },
[_]i32{ 19, -5, -3, 4 },
[_]i32{ @bitCast(@as(u32, 0x80000000)), 8, @bitCast(@as(u32, 0xf0000000)), 0 },
[_]i32{ @bitCast(@as(u32, 0x80000007)), 8, @bitCast(@as(u32, 0xf0000001)), -1 },
};
[_]i32{ 0, 1, 0, 0 },
[_]i32{ 0, -1, 0, 0 },
[_]i32{ 2, 1, 2, 0 },
[_]i32{ 2, -1, -2, 0 },
[_]i32{ -2, 1, -2, 0 },
[_]i32{ -2, -1, 2, 0 },
[_]i32{ 7, 5, 1, 2 },
[_]i32{ -7, 5, -1, -2 },
[_]i32{ 19, 5, 3, 4 },
[_]i32{ 19, -5, -3, 4 },
[_]i32{ @bitCast(@as(u32, 0x80000000)), 8, @bitCast(@as(u32, 0xf0000000)), 0 },
[_]i32{ @bitCast(@as(u32, 0x80000007)), 8, @bitCast(@as(u32, 0xf0000001)), -1 },
};
fn test_one_divmodsi4(a: i32, b: i32, expected_q: i32, expected_r: i32) !void {
var r: i32 = undefined;

View file

@ -40,7 +40,7 @@ inline fn popcountXi2(comptime ST: type, a: ST) i32 {
var x: UT = @bitCast(a);
x -= (x >> 1) & (~@as(UT, 0) / 3); // 0x55...55, aggregate duos
x = ((x >> 2) & (~@as(UT, 0) / 5)) // 0x33...33, aggregate nibbles
+ (x & (~@as(UT, 0) / 5));
+ (x & (~@as(UT, 0) / 5));
x += x >> 4;
x &= ~@as(UT, 0) / 17; // 0x0F...0F, aggregate bytes
// 8 most significant bits of x + (x<<8) + (x<<16) + ..

View file

@ -374,7 +374,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void {
// or not of the same marker type.
const should_close_list = last_pending_block.tag == .list and
(block_start.tag != .list_item or
block_start.data.list_item.marker != last_pending_block.data.list.marker);
block_start.data.list_item.marker != last_pending_block.data.list.marker);
// The last block should also be closed if the new block is not a table
// row, which is the only allowed child of a table.
const should_close_table = last_pending_block.tag == .table and

View file

@ -299,7 +299,7 @@ pub const Os = struct {
pub fn parse(str: []const u8) !WindowsVersion {
return std.meta.stringToEnum(WindowsVersion, str) orelse
@enumFromInt(std.fmt.parseInt(u32, str, 0) catch
return error.InvalidOperatingSystemVersion);
return error.InvalidOperatingSystemVersion);
}
/// This function is defined to serialize a Zig source code representation of this

View file

@ -9879,10 +9879,10 @@ pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8
pub const getcontext = if (builtin.target.abi.isAndroid() or builtin.target.os.tag == .openbsd)
{} // android bionic and openbsd libc does not implement getcontext
else if (native_os == .linux and builtin.target.abi.isMusl())
linux.getcontext
else
private.getcontext;
else if (native_os == .linux and builtin.target.abi.isMusl())
linux.getcontext
else
private.getcontext;
pub const max_align_t = if (native_abi == .msvc or native_abi == .itanium)
f64

View file

@ -692,7 +692,7 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
const client_key_exchange_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
array(u16, u8, .{@intFromEnum(tls.HandshakeType.client_key_exchange)} ++
array(u24, u8, array(u8, u8, key_share.secp256r1_kp.public_key.toUncompressedSec1())));
array(u24, u8, array(u8, u8, key_share.secp256r1_kp.public_key.toUncompressedSec1())));
const client_change_cipher_spec_msg = .{@intFromEnum(tls.ContentType.change_cipher_spec)} ++
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
array(u16, tls.ChangeCipherSpecType, .{.change_cipher_spec});
@ -720,11 +720,11 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
);
const client_verify_cleartext = .{@intFromEnum(tls.HandshakeType.finished)} ++
array(u24, u8, hmacExpandLabel(
P.Hmac,
&master_secret,
&.{ "client finished", &p.transcript_hash.peek() },
P.verify_data_length,
));
P.Hmac,
&master_secret,
&.{ "client finished", &p.transcript_hash.peek() },
P.verify_data_length,
));
p.transcript_hash.update(&client_verify_cleartext);
p.version = .{ .tls_1_2 = .{
.expected_server_verify_data = hmacExpandLabel(
@ -745,7 +745,7 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
var client_verify_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
array(u16, u8, nonce[P.fixed_iv_length..].* ++
@as([client_verify_cleartext.len + P.mac_length]u8, undefined));
@as([client_verify_cleartext.len + P.mac_length]u8, undefined));
P.AEAD.encrypt(
client_verify_msg[client_verify_msg.len - P.mac_length -
client_verify_cleartext.len ..][0..client_verify_cleartext.len],

View file

@ -689,15 +689,15 @@ pub const Module = switch (native_os) {
const o_file_path = mem.sliceTo(self.strings[symbol.ofile..], 0);
const o_file_info = self.ofiles.getPtr(o_file_path) orelse
(self.loadOFile(allocator, o_file_path) catch |err| switch (err) {
error.FileNotFound,
error.MissingDebugInfo,
error.InvalidDebugInfo,
=> return .{
.relocated_address = relocated_address,
.symbol = symbol,
},
else => return err,
});
error.FileNotFound,
error.MissingDebugInfo,
error.InvalidDebugInfo,
=> return .{
.relocated_address = relocated_address,
.symbol = symbol,
},
else => return err,
});
return .{
.relocated_address = relocated_address,

View file

@ -960,13 +960,13 @@ pub const Request = struct {
pub const WaitError = RequestError || SendError || TransferReadError ||
proto.HeadersParser.CheckCompleteHeadError || Response.ParseError ||
error{
TooManyHttpRedirects,
RedirectRequiresResend,
HttpRedirectLocationMissing,
HttpRedirectLocationInvalid,
CompressionInitializationFailed,
CompressionUnsupported,
};
TooManyHttpRedirects,
RedirectRequiresResend,
HttpRedirectLocationMissing,
HttpRedirectLocationInvalid,
CompressionInitializationFailed,
CompressionUnsupported,
};
/// Waits for a response from the server and parses any headers that are sent.
/// This function will block until the final response is received.
@ -1540,12 +1540,12 @@ pub fn connect(
pub const RequestError = ConnectTcpError || ConnectErrorPartial || Request.SendError ||
std.fmt.ParseIntError || Connection.WriteError ||
error{
UnsupportedUriScheme,
UriMissingHost,
UnsupportedUriScheme,
UriMissingHost,
CertificateBundleLoadFailure,
UnsupportedTransferEncoding,
};
CertificateBundleLoadFailure,
UnsupportedTransferEncoding,
};
pub const RequestOptions = struct {
version: http.Version = .@"HTTP/1.1",

View file

@ -2851,12 +2851,12 @@ pub fn renameatW(
rc =
windows.ntdll.NtSetInformationFile(
src_fd,
&io_status_block,
rename_info,
@intCast(struct_len), // already checked for error.NameTooLong
.FileRenameInformation,
);
src_fd,
&io_status_block,
rename_info,
@intCast(struct_len), // already checked for error.NameTooLong
.FileRenameInformation,
);
}
switch (rc) {

View file

@ -372,7 +372,7 @@ fn renderExpression(r: *Render, node: Ast.Node.Index, space: Space) Error!void {
if (!ais.indentStackEmpty() and
token_tags[i] != .colon and
((token_tags[i] != .semicolon and token_tags[i] != .comma) or
ais.lastSpaceModeIndent() < ais.currentIndent()))
ais.lastSpaceModeIndent() < ais.currentIndent()))
{
ais.popIndent();
try ais.pushIndent(.normal);
@ -1185,9 +1185,9 @@ fn renderVarDeclWithoutFixups(
{
const name_space = if (var_decl.ast.type_node == 0 and
(var_decl.ast.align_node != 0 or
var_decl.ast.addrspace_node != 0 or
var_decl.ast.section_node != 0 or
var_decl.ast.init_node != 0))
var_decl.ast.addrspace_node != 0 or
var_decl.ast.section_node != 0 or
var_decl.ast.init_node != 0))
Space.space
else
Space.none;

View file

@ -23443,7 +23443,7 @@ fn ptrCastFull(
errdefer msg.destroy(sema.gpa);
if (dest_info.flags.size == .many and
(src_info.flags.size == .slice or
(src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
(src_info.flags.size == .one and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
{
try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{});
} else {
@ -28136,9 +28136,9 @@ fn fieldCallBind(
const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]);
if (first_param_type.isGenericPoison() or
(first_param_type.zigTypeTag(zcu) == .pointer and
(first_param_type.ptrSize(zcu) == .one or
first_param_type.ptrSize(zcu) == .c) and
first_param_type.childType(zcu).eql(concrete_ty, zcu)))
(first_param_type.ptrSize(zcu) == .one or
first_param_type.ptrSize(zcu) == .c) and
first_param_type.childType(zcu).eql(concrete_ty, zcu)))
{
// Note that if the param type is generic poison, we know that it must
// specifically be `anytype` since it's the first parameter, meaning we
@ -29652,7 +29652,7 @@ fn coerceExtra(
if (dest_info.sentinel == .none or inst_info.sentinel == .none or
Air.internedToRef(dest_info.sentinel) !=
try sema.coerceInMemory(Value.fromInterned(inst_info.sentinel), Type.fromInterned(dest_info.child)))
try sema.coerceInMemory(Value.fromInterned(inst_info.sentinel), Type.fromInterned(dest_info.child)))
break :p;
const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty);
@ -30492,12 +30492,12 @@ pub fn coerceInMemoryAllowed(
}
const ok_sent = (dest_info.sentinel == null and src_info.sentinel == null) or
(src_info.sentinel != null and
dest_info.sentinel != null and
dest_info.sentinel.?.eql(
try pt.getCoerced(src_info.sentinel.?, dest_info.elem_type),
dest_info.elem_type,
zcu,
));
dest_info.sentinel != null and
dest_info.sentinel.?.eql(
try pt.getCoerced(src_info.sentinel.?, dest_info.elem_type),
dest_info.elem_type,
zcu,
));
if (!ok_sent) {
return .{ .array_sentinel = .{
.actual = src_info.sentinel orelse Value.@"unreachable",

View file

@ -610,11 +610,12 @@ pub fn hasRuntimeBitsInner(
// in which case we want control flow to continue down below.
if (tag_ty != .none and
try Type.fromInterned(tag_ty).hasRuntimeBitsInner(
ignore_comptime_only,
strat,
zcu,
tid,
)) {
ignore_comptime_only,
strat,
zcu,
tid,
))
{
return true;
}
},

View file

@ -1496,8 +1496,8 @@ pub const SrcLoc = struct {
const case = tree.fullSwitchCase(case_node).?;
const is_special = (case.ast.values.len == 0) or
(case.ast.values.len == 1 and
node_tags[case.ast.values[0]] == .identifier and
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
node_tags[case.ast.values[0]] == .identifier and
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
if (!is_special) continue;
return tree.nodeToSpan(case_node);
@ -1516,8 +1516,8 @@ pub const SrcLoc = struct {
const case = tree.fullSwitchCase(case_node).?;
const is_special = (case.ast.values.len == 0) or
(case.ast.values.len == 1 and
node_tags[case.ast.values[0]] == .identifier and
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
node_tags[case.ast.values[0]] == .identifier and
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
if (is_special) continue;
for (case.ast.values) |item_node| {

View file

@ -685,8 +685,7 @@ fn restoreState(func: *Func, state: State, deaths: []const Air.Inst.Index, compt
const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
if (opts.update_tracking)
{} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa);
if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa);
var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
stack.get(),
@ -2260,7 +2259,7 @@ fn airIntCast(func: *Func, inst: Air.Inst.Index) !void {
const dst_mcv = if (dst_int_info.bits <= src_storage_bits and
math.divCeil(u16, dst_int_info.bits, 64) catch unreachable ==
math.divCeil(u32, src_storage_bits, 64) catch unreachable and
math.divCeil(u32, src_storage_bits, 64) catch unreachable and
func.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: {
const dst_mcv = try func.allocRegOrMem(dst_ty, inst, true);
try func.genCopy(min_ty, dst_mcv, src_mcv);
@ -2311,9 +2310,9 @@ fn airNot(func: *Func, inst: Air.Inst.Index) !void {
const dst_reg: Register =
if (func.reuseOperand(inst, ty_op.operand, 0, operand) and operand == .register)
operand.register
else
(try func.allocRegOrMem(func.typeOfIndex(inst), inst, true)).register;
operand.register
else
(try func.allocRegOrMem(func.typeOfIndex(inst), inst, true)).register;
switch (ty.zigTypeTag(zcu)) {
.bool => {
@ -6222,11 +6221,11 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
const instruction: union(enum) { mnem: Mnemonic, pseudo: Pseudo } =
if (std.meta.stringToEnum(Mnemonic, mnem_str)) |mnem|
.{ .mnem = mnem }
else if (std.meta.stringToEnum(Pseudo, mnem_str)) |pseudo|
.{ .pseudo = pseudo }
else
return func.fail("invalid mnem str '{s}'", .{mnem_str});
.{ .mnem = mnem }
else if (std.meta.stringToEnum(Pseudo, mnem_str)) |pseudo|
.{ .pseudo = pseudo }
else
return func.fail("invalid mnem str '{s}'", .{mnem_str});
const Operand = union(enum) {
none,

View file

@ -82655,8 +82655,7 @@ fn restoreState(self: *CodeGen, state: State, deaths: []const Air.Inst.Index, co
const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
if (opts.update_tracking)
{} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
stack.get(),
@ -83216,7 +83215,7 @@ fn airIntCast(self: *CodeGen, inst: Air.Inst.Index) !void {
const dst_mcv = if ((if (src_mcv.getReg()) |src_reg| src_reg.class() == .general_purpose else src_abi_size > 8) and
dst_int_info.bits <= src_storage_bits and
std.math.divCeil(u16, dst_int_info.bits, 64) catch unreachable ==
std.math.divCeil(u32, src_storage_bits, 64) catch unreachable and
std.math.divCeil(u32, src_storage_bits, 64) catch unreachable and
self.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: {
const dst_mcv = try self.allocRegOrMem(inst, true);
try self.genCopy(min_ty, dst_mcv, src_mcv, .{});
@ -84695,10 +84694,10 @@ fn genIntMulDivOpMir(self: *CodeGen, tag: Mir.Inst.FixedTag, ty: Type, lhs: MCVa
._ => {
const hi_reg: Register =
switch (bit_size) {
8 => .ah,
16, 32, 64 => .edx,
else => unreachable,
};
8 => .ah,
16, 32, 64 => .edx,
else => unreachable,
};
try self.asmRegisterRegister(.{ ._, .xor }, hi_reg, hi_reg);
},
.i_ => try self.asmOpOnly(.{ ._, switch (bit_size) {
@ -89019,9 +89018,9 @@ fn genShiftBinOpMir(
.size = .fromSize(abi_size),
.disp = std.math.cast(i32, @as(i64, @bitCast(addr))) orelse
return self.fail("TODO genShiftBinOpMir between {s} and {s}", .{
@tagName(lhs_mcv),
@tagName(shift_mcv),
}),
@tagName(lhs_mcv),
@tagName(shift_mcv),
}),
} },
},
.indirect => |reg_off| .{
@ -89761,17 +89760,17 @@ fn genBinOp(
const ordered_air: [2]Air.Inst.Ref = if (lhs_ty.isVector(zcu) and
switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
.bool => false,
.int => switch (air_tag) {
.cmp_lt, .cmp_gte => true,
else => false,
},
.float => switch (air_tag) {
.cmp_gte, .cmp_gt => true,
else => false,
},
else => unreachable,
}) .{ rhs_air, lhs_air } else .{ lhs_air, rhs_air };
.bool => false,
.int => switch (air_tag) {
.cmp_lt, .cmp_gte => true,
else => false,
},
.float => switch (air_tag) {
.cmp_gte, .cmp_gt => true,
else => false,
},
else => unreachable,
}) .{ rhs_air, lhs_air } else .{ lhs_air, rhs_air };
if (lhs_ty.isAbiInt(zcu)) for (ordered_air) |op_air| {
switch (try self.resolveInst(op_air)) {
@ -91776,13 +91775,13 @@ fn genIntMulComplexOpMir(self: *CodeGen, dst_ty: Type, dst_mcv: MCValue, src_mcv
.size = .fromSize(abi_size),
.disp = std.math.cast(i32, @as(i64, @bitCast(addr))) orelse
return self.asmRegisterRegister(
.{ .i_, .mul },
dst_alias,
registerAlias(
try self.copyToTmpRegister(dst_ty, resolved_src_mcv),
abi_size,
.{ .i_, .mul },
dst_alias,
registerAlias(
try self.copyToTmpRegister(dst_ty, resolved_src_mcv),
abi_size,
),
),
),
} },
},
.indirect => |reg_off| .{
@ -94101,9 +94100,9 @@ fn airAsm(self: *CodeGen, inst: Air.Inst.Index) !void {
std.mem.eql(u8, rest, "r,m") or std.mem.eql(u8, rest, "m,r"))
self.register_manager.tryAllocReg(maybe_inst, abi.RegisterClass.gp) orelse
if (output != .none)
null
else
return self.fail("ran out of registers lowering inline asm", .{})
null
else
return self.fail("ran out of registers lowering inline asm", .{})
else if (std.mem.startsWith(u8, rest, "{") and std.mem.endsWith(u8, rest, "}"))
parseRegName(rest["{".len .. rest.len - "}".len]) orelse
return self.fail("invalid register constraint: '{s}'", .{constraint})
@ -96965,9 +96964,9 @@ fn airAtomicLoad(self: *CodeGen, inst: Air.Inst.Index) !void {
const dst_mcv =
if (self.reuseOperand(inst, atomic_load.ptr, 0, ptr_mcv))
ptr_mcv
else
try self.allocRegOrMem(inst, true);
ptr_mcv
else
try self.allocRegOrMem(inst, true);
try self.load(dst_mcv, ptr_ty, ptr_mcv);
return self.finishAir(inst, dst_mcv, .{ atomic_load.ptr, .none, .none });
@ -103712,9 +103711,9 @@ const Select = struct {
if (cg.intInfo(ty.childType(zcu))) |int_info| int_info.signedness == .signed else false,
.signed_int_or_full_vec => |size| ty.isVector(zcu) and @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu) and
if (cg.intInfo(ty.childType(zcu))) |int_info| switch (int_info.signedness) {
.signed => true,
.unsigned => int_info.bits >= 8 and std.math.isPowerOfTwo(int_info.bits),
} else false,
.signed => true,
.unsigned => int_info.bits >= 8 and std.math.isPowerOfTwo(int_info.bits),
} else false,
.unsigned_int_vec => |size| ty.isVector(zcu) and @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu) and
if (cg.intInfo(ty.childType(zcu))) |int_info| int_info.signedness == .unsigned else false,
.size => |size| @divExact(size.bitSize(cg.target), 8) >= ty.abiSize(zcu),
@ -103736,26 +103735,26 @@ const Select = struct {
if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is.bitSize(cg.target) >= int_info.bits else false,
.scalar_signed_int => |of_is| @divExact(of_is.of.bitSize(cg.target), 8) >= cg.unalignedSize(ty) and
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
of_is.is.bitSize(cg.target) >= int_info.bits else false,
of_is.is.bitSize(cg.target) >= int_info.bits else false,
.scalar_unsigned_int => |of_is| @divExact(of_is.of.bitSize(cg.target), 8) >= cg.unalignedSize(ty) and
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
of_is.is.bitSize(cg.target) >= int_info.bits else false,
of_is.is.bitSize(cg.target) >= int_info.bits else false,
.multiple_scalar_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is.bitSize(cg.target) >= int_info.bits else false,
.multiple_scalar_signed_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
of_is.is.bitSize(cg.target) >= int_info.bits else false,
of_is.is.bitSize(cg.target) >= int_info.bits else false,
.multiple_scalar_unsigned_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
of_is.is.bitSize(cg.target) >= int_info.bits else false,
of_is.is.bitSize(cg.target) >= int_info.bits else false,
.multiple_scalar_exact_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
if (cg.intInfo(ty.scalarType(zcu))) |int_info| of_is.is == int_info.bits else false,
.multiple_scalar_exact_signed_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .signed and
of_is.is == int_info.bits else false,
of_is.is == int_info.bits else false,
.multiple_scalar_exact_unsigned_int => |of_is| ty.abiSize(zcu) % @divExact(of_is.of.bitSize(cg.target), 8) == 0 and
if (cg.intInfo(ty.scalarType(zcu))) |int_info| int_info.signedness == .unsigned and
of_is.is == int_info.bits else false,
of_is.is == int_info.bits else false,
.scalar_remainder_int => |of_is| if (cg.intInfo(ty.scalarType(zcu))) |int_info|
of_is.is.bitSize(cg.target) >= (int_info.bits - 1) % of_is.of.bitSize(cg.target) + 1
else

View file

@ -423,7 +423,7 @@ pub fn generateSymbol(
const padding = abi_size -
(math.cast(usize, Type.fromInterned(vector_type.child).abiSize(zcu) * vector_type.len) orelse
return error.Overflow);
return error.Overflow);
if (padding > 0) try code.appendNTimes(gpa, 0, padding);
}
},

View file

@ -1990,7 +1990,7 @@ pub const DeclGen = struct {
if (dest_bits <= 64 and src_bits <= 64) {
const needs_cast = src_int_info == null or
(toCIntBits(dest_int_info.bits) != toCIntBits(src_int_info.?.bits) or
dest_int_info.signedness != src_int_info.?.signedness);
dest_int_info.signedness != src_int_info.?.signedness);
return !needs_cast and !src_is_ptr;
} else return false;
}
@ -2031,7 +2031,7 @@ pub const DeclGen = struct {
if (dest_bits <= 64 and src_bits <= 64) {
const needs_cast = src_int_info == null or
(toCIntBits(dest_int_info.bits) != toCIntBits(src_int_info.?.bits) or
dest_int_info.signedness != src_int_info.?.signedness);
dest_int_info.signedness != src_int_info.?.signedness);
if (needs_cast) {
try w.writeByte('(');
@ -4348,7 +4348,7 @@ fn airEquality(
.aligned, .array, .vector, .fwd_decl, .function => unreachable,
.aggregate => |aggregate| if (aggregate.fields.len == 2 and
(aggregate.fields.at(0, ctype_pool).name.index == .is_null or
aggregate.fields.at(1, ctype_pool).name.index == .is_null))
aggregate.fields.at(1, ctype_pool).name.index == .is_null))
{
try f.writeCValueMember(writer, lhs, .{ .identifier = "is_null" });
try writer.writeAll(" || ");

View file

@ -758,12 +758,12 @@ pub const Info = union(enum) {
fn tag(pointer_info: Pointer) Pool.Tag {
return @enumFromInt(@intFromEnum(Pool.Tag.pointer) +
@as(u2, @bitCast(packed struct(u2) {
@"const": bool,
@"volatile": bool,
}{
.@"const" = pointer_info.@"const",
.@"volatile" = pointer_info.@"volatile",
})));
@"const": bool,
@"volatile": bool,
}{
.@"const" = pointer_info.@"const",
.@"volatile" = pointer_info.@"volatile",
})));
}
};
@ -887,24 +887,24 @@ pub const Info = union(enum) {
pool_adapter.eql(lhs_vector_info.elem_ctype, rhs_info.vector.elem_ctype),
.fwd_decl => |lhs_fwd_decl_info| lhs_fwd_decl_info.tag == rhs_info.fwd_decl.tag and
switch (lhs_fwd_decl_info.name) {
.anon => |lhs_anon| rhs_info.fwd_decl.name == .anon and lhs_anon.eqlAdapted(
lhs_pool,
rhs_info.fwd_decl.name.anon,
rhs_pool,
pool_adapter,
),
.index => |lhs_index| rhs_info.fwd_decl.name == .index and
lhs_index == rhs_info.fwd_decl.name.index,
},
.anon => |lhs_anon| rhs_info.fwd_decl.name == .anon and lhs_anon.eqlAdapted(
lhs_pool,
rhs_info.fwd_decl.name.anon,
rhs_pool,
pool_adapter,
),
.index => |lhs_index| rhs_info.fwd_decl.name == .index and
lhs_index == rhs_info.fwd_decl.name.index,
},
.aggregate => |lhs_aggregate_info| lhs_aggregate_info.tag == rhs_info.aggregate.tag and
lhs_aggregate_info.@"packed" == rhs_info.aggregate.@"packed" and
switch (lhs_aggregate_info.name) {
.anon => |lhs_anon| rhs_info.aggregate.name == .anon and
lhs_anon.index == rhs_info.aggregate.name.anon.index and
lhs_anon.id == rhs_info.aggregate.name.anon.id,
.fwd_decl => |lhs_fwd_decl| rhs_info.aggregate.name == .fwd_decl and
pool_adapter.eql(lhs_fwd_decl, rhs_info.aggregate.name.fwd_decl),
} and lhs_aggregate_info.fields.eqlAdapted(
.anon => |lhs_anon| rhs_info.aggregate.name == .anon and
lhs_anon.index == rhs_info.aggregate.name.anon.index and
lhs_anon.id == rhs_info.aggregate.name.anon.id,
.fwd_decl => |lhs_fwd_decl| rhs_info.aggregate.name == .fwd_decl and
pool_adapter.eql(lhs_fwd_decl, rhs_info.aggregate.name.fwd_decl),
} and lhs_aggregate_info.fields.eqlAdapted(
lhs_pool,
rhs_info.aggregate.fields,
rhs_pool,
@ -913,13 +913,12 @@ pub const Info = union(enum) {
.function => |lhs_function_info| lhs_function_info.param_ctypes.len ==
rhs_info.function.param_ctypes.len and
pool_adapter.eql(lhs_function_info.return_ctype, rhs_info.function.return_ctype) and
for (0..lhs_function_info.param_ctypes.len) |param_index|
{
if (!pool_adapter.eql(
lhs_function_info.param_ctypes.at(param_index, lhs_pool),
rhs_info.function.param_ctypes.at(param_index, rhs_pool),
)) break false;
} else true,
for (0..lhs_function_info.param_ctypes.len) |param_index| {
if (!pool_adapter.eql(
lhs_function_info.param_ctypes.at(param_index, lhs_pool),
rhs_info.function.param_ctypes.at(param_index, rhs_pool),
)) break false;
} else true,
};
}
};
@ -2301,13 +2300,13 @@ pub const Pool = struct {
const return_type = Type.fromInterned(func_info.return_type);
const return_ctype: CType =
if (!ip.isNoReturn(func_info.return_type)) try pool.fromType(
allocator,
scratch,
return_type,
pt,
mod,
kind.asParameter(),
) else .void;
allocator,
scratch,
return_type,
pt,
mod,
kind.asParameter(),
) else .void;
for (0..func_info.param_types.len) |param_index| {
const param_type = Type.fromInterned(
func_info.param_types.get(ip)[param_index],

View file

@ -388,7 +388,7 @@ const DataLayoutBuilder = struct {
self.target.cpu.arch != .riscv64 and
self.target.cpu.arch != .loongarch64 and
!(self.target.cpu.arch == .aarch64 and
(self.target.os.tag == .uefi or self.target.os.tag == .windows)) and
(self.target.os.tag == .uefi or self.target.os.tag == .windows)) and
self.target.cpu.arch != .bpfeb and self.target.cpu.arch != .bpfel) continue;
try writer.writeAll("-p");
if (info.llvm != .default) try writer.print("{d}", .{@intFromEnum(info.llvm)});
@ -859,55 +859,54 @@ pub const Object = struct {
builder.data_layout = try builder.fmt("{}", .{DataLayoutBuilder{ .target = target }});
const debug_compile_unit, const debug_enums_fwd_ref, const debug_globals_fwd_ref =
if (!builder.strip)
debug_info: {
// We fully resolve all paths at this point to avoid lack of
// source line info in stack traces or lack of debugging
// information which, if relative paths were used, would be
// very location dependent.
// TODO: the only concern I have with this is WASI as either host or target, should
// we leave the paths as relative then?
// TODO: This is totally wrong. In dwarf, paths are encoded as relative to
// a particular directory, and then the directory path is specified elsewhere.
// In the compiler frontend we have it stored correctly in this
// way already, but here we throw all that sweet information
// into the garbage can by converting into absolute paths. What
// a terrible tragedy.
const compile_unit_dir = blk: {
if (comp.zcu) |zcu| m: {
const d = try zcu.main_mod.root.joinString(arena, "");
if (d.len == 0) break :m;
if (std.fs.path.isAbsolute(d)) break :blk d;
break :blk std.fs.realpathAlloc(arena, d) catch break :blk d;
}
break :blk try std.process.getCwdAlloc(arena);
};
if (!builder.strip) debug_info: {
// We fully resolve all paths at this point to avoid lack of
// source line info in stack traces or lack of debugging
// information which, if relative paths were used, would be
// very location dependent.
// TODO: the only concern I have with this is WASI as either host or target, should
// we leave the paths as relative then?
// TODO: This is totally wrong. In dwarf, paths are encoded as relative to
// a particular directory, and then the directory path is specified elsewhere.
// In the compiler frontend we have it stored correctly in this
// way already, but here we throw all that sweet information
// into the garbage can by converting into absolute paths. What
// a terrible tragedy.
const compile_unit_dir = blk: {
if (comp.zcu) |zcu| m: {
const d = try zcu.main_mod.root.joinString(arena, "");
if (d.len == 0) break :m;
if (std.fs.path.isAbsolute(d)) break :blk d;
break :blk std.fs.realpathAlloc(arena, d) catch break :blk d;
}
break :blk try std.process.getCwdAlloc(arena);
};
const debug_file = try builder.debugFile(
try builder.metadataString(comp.root_name),
try builder.metadataString(compile_unit_dir),
);
const debug_file = try builder.debugFile(
try builder.metadataString(comp.root_name),
try builder.metadataString(compile_unit_dir),
);
const debug_enums_fwd_ref = try builder.debugForwardReference();
const debug_globals_fwd_ref = try builder.debugForwardReference();
const debug_enums_fwd_ref = try builder.debugForwardReference();
const debug_globals_fwd_ref = try builder.debugForwardReference();
const debug_compile_unit = try builder.debugCompileUnit(
debug_file,
// Don't use the version string here; LLVM misparses it when it
// includes the git revision.
try builder.metadataStringFmt("zig {d}.{d}.{d}", .{
build_options.semver.major,
build_options.semver.minor,
build_options.semver.patch,
}),
debug_enums_fwd_ref,
debug_globals_fwd_ref,
.{ .optimized = comp.root_mod.optimize_mode != .Debug },
);
const debug_compile_unit = try builder.debugCompileUnit(
debug_file,
// Don't use the version string here; LLVM misparses it when it
// includes the git revision.
try builder.metadataStringFmt("zig {d}.{d}.{d}", .{
build_options.semver.major,
build_options.semver.minor,
build_options.semver.patch,
}),
debug_enums_fwd_ref,
debug_globals_fwd_ref,
.{ .optimized = comp.root_mod.optimize_mode != .Debug },
);
try builder.metadataNamed(try builder.metadataString("llvm.dbg.cu"), &.{debug_compile_unit});
break :debug_info .{ debug_compile_unit, debug_enums_fwd_ref, debug_globals_fwd_ref };
} else .{.none} ** 3;
try builder.metadataNamed(try builder.metadataString("llvm.dbg.cu"), &.{debug_compile_unit});
break :debug_info .{ debug_compile_unit, debug_enums_fwd_ref, debug_globals_fwd_ref };
} else .{.none} ** 3;
const obj = try arena.create(Object);
obj.* = .{
@ -2759,9 +2758,9 @@ pub const Object = struct {
const full_fields: [2]Builder.Metadata =
if (layout.tag_align.compare(.gte, layout.payload_align))
.{ debug_tag_type, debug_payload_type }
else
.{ debug_payload_type, debug_tag_type };
.{ debug_tag_type, debug_payload_type }
else
.{ debug_payload_type, debug_tag_type };
const debug_tagged_union_type = try o.builder.debugStructType(
try o.builder.metadataString(name),
@ -4551,11 +4550,11 @@ pub const Object = struct {
// instruction is followed by a `wrap_optional`, it will return this value
// verbatim, and the result should test as non-null.
switch (zcu.getTarget().ptrBitWidth()) {
16 => 0xaaaa,
32 => 0xaaaaaaaa,
64 => 0xaaaaaaaa_aaaaaaaa,
else => unreachable,
};
16 => 0xaaaa,
32 => 0xaaaaaaaa,
64 => 0xaaaaaaaa_aaaaaaaa,
else => unreachable,
};
const llvm_usize = try o.lowerType(Type.usize);
const llvm_ptr_ty = try o.lowerType(ptr_ty);
return o.builder.castConst(.inttoptr, try o.builder.intConst(llvm_usize, int), llvm_ptr_ty);
@ -9544,7 +9543,7 @@ pub const FuncGen = struct {
if (llvm_dest_ty.isStruct(&o.builder) or
((operand_ty.zigTypeTag(zcu) == .vector or inst_ty.zigTypeTag(zcu) == .vector) and
operand_ty.bitSize(zcu) != inst_ty.bitSize(zcu)))
operand_ty.bitSize(zcu) != inst_ty.bitSize(zcu)))
{
// Both our operand and our result are values, not pointers,
// but LLVM won't let us bitcast struct values or vectors with padding bits.

View file

@ -3821,38 +3821,38 @@ const msdos_stub: [120]u8 = .{
0x40, 0x00, // Absolute offset to relocation table. 64 matches the header size (all bytes before the MS-DOS stub program).
0x00, 0x00, // Overlay number. Zero means this is the main executable.
}
// Reserved words.
++ .{ 0x00, 0x00 } ** 4
// OEM-related fields.
++ .{
0x00, 0x00, // OEM identifier.
0x00, 0x00, // OEM information.
}
// Reserved words.
++ .{ 0x00, 0x00 } ** 10
// Address of the PE header (a long). This matches the size of this entire MS-DOS stub, so that's the address of what's after this MS-DOS stub.
++ .{ 0x78, 0x00, 0x00, 0x00 }
// What follows is a 16-bit x86 MS-DOS program of 7 instructions that prints the bytes after these instructions and then exits.
++ .{
// Set the value of the data segment to the same value as the code segment.
0x0e, // push cs
0x1f, // pop ds
// Set the DX register to the address of the message.
// If you count all bytes of these 7 instructions you get 14, so that's the address of what's after these instructions.
0xba, 14, 0x00, // mov dx, 14
// Set AH to the system call code for printing a message.
0xb4, 0x09, // mov ah, 0x09
// Perform the system call to print the message.
0xcd, 0x21, // int 0x21
// Set AH to 0x4c which is the system call code for exiting, and set AL to 0x01 which is the exit code.
0xb8, 0x01, 0x4c, // mov ax, 0x4c01
// Peform the system call to exit the program with exit code 1.
0xcd, 0x21, // int 0x21
}
// Message to print.
++ "This program cannot be run in DOS mode.".*
// Message terminators.
++ .{
'$', // We do not pass a length to the print system call; the string is terminated by this character.
0x00, 0x00, // Terminating zero bytes.
};
// Reserved words.
++ .{ 0x00, 0x00 } ** 4
// OEM-related fields.
++ .{
0x00, 0x00, // OEM identifier.
0x00, 0x00, // OEM information.
}
// Reserved words.
++ .{ 0x00, 0x00 } ** 10
// Address of the PE header (a long). This matches the size of this entire MS-DOS stub, so that's the address of what's after this MS-DOS stub.
++ .{ 0x78, 0x00, 0x00, 0x00 }
// What follows is a 16-bit x86 MS-DOS program of 7 instructions that prints the bytes after these instructions and then exits.
++ .{
// Set the value of the data segment to the same value as the code segment.
0x0e, // push cs
0x1f, // pop ds
// Set the DX register to the address of the message.
// If you count all bytes of these 7 instructions you get 14, so that's the address of what's after these instructions.
0xba, 14, 0x00, // mov dx, 14
// Set AH to the system call code for printing a message.
0xb4, 0x09, // mov ah, 0x09
// Perform the system call to print the message.
0xcd, 0x21, // int 0x21
// Set AH to 0x4c which is the system call code for exiting, and set AL to 0x01 which is the exit code.
0xb8, 0x01, 0x4c, // mov ax, 0x4c01
// Peform the system call to exit the program with exit code 1.
0xcd, 0x21, // int 0x21
}
// Message to print.
++ "This program cannot be run in DOS mode.".*
// Message terminators.
++ .{
'$', // We do not pass a length to the print system call; the string is terminated by this character.
0x00, 0x00, // Terminating zero bytes.
};

View file

@ -1995,30 +1995,30 @@ pub const WipNav = struct {
errdefer _ = if (!decl_gop.found_existing) dwarf.decls.pop();
const was_generic_decl = decl_gop.found_existing and
switch (try dwarf.debug_info.declAbbrevCode(wip_nav.unit, decl_gop.value_ptr.*)) {
.null,
.decl_alias,
.decl_empty_enum,
.decl_enum,
.decl_namespace_struct,
.decl_struct,
.decl_packed_struct,
.decl_union,
.decl_var,
.decl_const,
.decl_const_runtime_bits,
.decl_const_comptime_state,
.decl_const_runtime_bits_comptime_state,
.decl_empty_func,
.decl_func,
.decl_empty_func_generic,
.decl_func_generic,
=> false,
.generic_decl_var,
.generic_decl_const,
.generic_decl_func,
=> true,
else => unreachable,
};
.null,
.decl_alias,
.decl_empty_enum,
.decl_enum,
.decl_namespace_struct,
.decl_struct,
.decl_packed_struct,
.decl_union,
.decl_var,
.decl_const,
.decl_const_runtime_bits,
.decl_const_comptime_state,
.decl_const_runtime_bits_comptime_state,
.decl_empty_func,
.decl_func,
.decl_empty_func_generic,
.decl_func_generic,
=> false,
.generic_decl_var,
.generic_decl_const,
.generic_decl_func,
=> true,
else => unreachable,
};
if (parent_type.getCaptures(zcu).len == 0) {
if (was_generic_decl) try dwarf.freeCommonEntry(wip_nav.unit, decl_gop.value_ptr.*);
decl_gop.value_ptr.* = orig_entry;

View file

@ -236,11 +236,11 @@ pub fn validateEFlags(
const fabi: riscv.Eflags.FloatAbi =
if (std.Target.riscv.featureSetHas(features, .d))
.double
else if (std.Target.riscv.featureSetHas(features, .f))
.single
else
.soft;
.double
else if (std.Target.riscv.featureSetHas(features, .f))
.single
else
.soft;
if (flags.fabi != fabi) {
any_errors = true;

View file

@ -217,20 +217,20 @@ fn initSections(elf_file: *Elf) !void {
if (elf_file.section_indexes.eh_frame == null) {
elf_file.section_indexes.eh_frame = elf_file.sectionByName(".eh_frame") orelse
try elf_file.addSection(.{
.name = try elf_file.insertShString(".eh_frame"),
.type = if (elf_file.getTarget().cpu.arch == .x86_64)
elf.SHT_X86_64_UNWIND
else
elf.SHT_PROGBITS,
.flags = elf.SHF_ALLOC,
.addralign = elf_file.ptrWidthBytes(),
});
.name = try elf_file.insertShString(".eh_frame"),
.type = if (elf_file.getTarget().cpu.arch == .x86_64)
elf.SHT_X86_64_UNWIND
else
elf.SHT_PROGBITS,
.flags = elf.SHF_ALLOC,
.addralign = elf_file.ptrWidthBytes(),
});
}
elf_file.section_indexes.eh_frame_rela = elf_file.sectionByName(".rela.eh_frame") orelse
try elf_file.addRelaShdr(
try elf_file.insertShString(".rela.eh_frame"),
elf_file.section_indexes.eh_frame.?,
);
try elf_file.insertShString(".rela.eh_frame"),
elf_file.section_indexes.eh_frame.?,
);
}
try initComdatGroups(elf_file);

View file

@ -551,7 +551,7 @@ pub const GotSection = struct {
switch (entry.tag) {
.got => if (symbol.?.flags.import or symbol.?.isIFunc(elf_file) or
((elf_file.isEffectivelyDynLib() or (elf_file.base.isExe() and comp.config.pie)) and
!symbol.?.isAbs(elf_file)))
!symbol.?.isAbs(elf_file)))
{
num += 1;
},

View file

@ -1617,14 +1617,14 @@ fn initOutputSections(self: *MachO) !void {
}
self.text_sect_index = self.getSectionByName("__TEXT", "__text") orelse
try self.addSection("__TEXT", "__text", .{
.alignment = switch (self.getTarget().cpu.arch) {
.x86_64 => 0,
.aarch64 => 2,
else => unreachable,
},
.flags = macho.S_REGULAR |
macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
});
.alignment = switch (self.getTarget().cpu.arch) {
.x86_64 => 0,
.aarch64 => 2,
else => unreachable,
},
.flags = macho.S_REGULAR |
macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
});
self.data_sect_index = self.getSectionByName("__DATA", "__data") orelse
try self.addSection("__DATA", "__data", .{});
}

View file

@ -149,10 +149,10 @@ pub fn initOutputSection(sect: macho.section_64, macho_file: *MachO) !u8 {
if (macho_file.base.isRelocatable()) {
const osec = macho_file.getSectionByName(sect.segName(), sect.sectName()) orelse
try macho_file.addSection(
sect.segName(),
sect.sectName(),
.{ .flags = sect.flags },
);
sect.segName(),
sect.sectName(),
.{ .flags = sect.flags },
);
return osec;
}

View file

@ -1104,8 +1104,8 @@ fn createTlvDescriptor(
const sect_index = macho_file.getSectionByName("__DATA", "__thread_vars") orelse
try macho_file.addSection("__DATA", "__thread_vars", .{
.flags = macho.S_THREAD_LOCAL_VARIABLES,
});
.flags = macho.S_THREAD_LOCAL_VARIABLES,
});
sym.out_n_sect = sect_index;
atom.out_n_sect = sect_index;

View file

@ -102,8 +102,8 @@ fn mark(roots: []*Atom, objects: []const File.Index, macho_file: *MachO) void {
const isec = atom.getInputSection(macho_file);
if (isec.isDontDeadStripIfReferencesLive() and
!(mem.eql(u8, isec.sectName(), "__eh_frame") or
mem.eql(u8, isec.sectName(), "__compact_unwind") or
isec.attrs() & macho.S_ATTR_DEBUG != 0) and
mem.eql(u8, isec.sectName(), "__compact_unwind") or
isec.attrs() & macho.S_ATTR_DEBUG != 0) and
!atom.isAlive() and refersLive(atom, macho_file))
{
markLive(atom, macho_file);

View file

@ -5919,8 +5919,8 @@ pub const ClangArgIterator = struct {
self.arg_iterator_response_file =
initArgIteratorResponseFile(arena, resp_file_path) catch |err| {
fatal("unable to read response file '{s}': {s}", .{ resp_file_path, @errorName(err) });
};
fatal("unable to read response file '{s}': {s}", .{ resp_file_path, @errorName(err) });
};
// NOTE: The ArgIteratorResponseFile returns tokens from next() that are slices of an
// internal buffer. This internal buffer is arena allocated, so it is not cleaned up here.
@ -6233,8 +6233,8 @@ fn cmdAstCheck(
file.tree.?.tokens.len * (@sizeOf(std.zig.Token.Tag) + @sizeOf(Ast.ByteOffset));
const tree_bytes = @sizeOf(Ast) + file.tree.?.nodes.len *
(@sizeOf(Ast.Node.Tag) +
@sizeOf(Ast.Node.Data) +
@sizeOf(Ast.TokenIndex));
@sizeOf(Ast.Node.Data) +
@sizeOf(Ast.TokenIndex));
const instruction_bytes = file.zir.?.instructions.len *
// Here we don't use @sizeOf(Zir.Inst.Data) because it would include
// the debug safety tag but we want to measure release size.

View file

@ -2570,9 +2570,9 @@ fn transInitListExprRecord(
// Unions and Structs are both represented as RecordDecl
const record_ty = ty.getAsRecordType() orelse
blk: {
is_union_type = true;
break :blk ty.getAsUnionType();
} orelse unreachable;
is_union_type = true;
break :blk ty.getAsUnionType();
} orelse unreachable;
const record_decl = record_ty.getDecl();
const record_def = record_decl.getDefinition() orelse
unreachable;
@ -4006,7 +4006,7 @@ fn transCPtrCast(
if (!src_ty.isArrayType() and ((src_child_type.isConstQualified() and
!child_type.isConstQualified()) or
(src_child_type.isVolatileQualified() and
!child_type.isVolatileQualified())))
!child_type.isVolatileQualified())))
{
return removeCVQualifiers(c, dst_type_node, expr);
} else {
@ -4092,8 +4092,8 @@ fn transFloatingLiteralQuad(c: *Context, expr: *const clang.FloatingLiteral, use
false;
break :fmt_decimal if (could_roundtrip) try c.arena.dupe(u8, temp_str) else null;
}
// otherwise, fall back to the hexadecimal format
orelse try std.fmt.allocPrint(c.arena, "{x}", .{quad});
// otherwise, fall back to the hexadecimal format
orelse try std.fmt.allocPrint(c.arena, "{x}", .{quad});
var node = try Tag.float_literal.create(c.arena, str);
if (is_negative) node = try Tag.negate.create(c.arena, node);
@ -5080,15 +5080,14 @@ fn finishTransFnProto(
const is_noalias = param_qt.isRestrictQualified();
const param_name: ?[]const u8 =
if (fn_decl) |decl|
blk: {
const param = decl.getParamDecl(@as(c_uint, @intCast(i)));
const param_name: []const u8 = try c.str(@as(*const clang.NamedDecl, @ptrCast(param)).getName_bytes_begin());
if (param_name.len < 1)
break :blk null;
if (fn_decl) |decl| blk: {
const param = decl.getParamDecl(@as(c_uint, @intCast(i)));
const param_name: []const u8 = try c.str(@as(*const clang.NamedDecl, @ptrCast(param)).getName_bytes_begin());
if (param_name.len < 1)
break :blk null;
break :blk param_name;
} else null;
break :blk param_name;
} else null;
const type_node = try transQualType(c, scope, param_qt, source_loc);
fn_params.addOneAssumeCapacity().* = .{

View file

@ -59,8 +59,8 @@ test "exporting comptime-known value" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64 and
(builtin.target.ofmt != .elf and
builtin.target.ofmt != .macho and
builtin.target.ofmt != .coff)) return error.SkipZigTest;
builtin.target.ofmt != .macho and
builtin.target.ofmt != .coff)) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;

View file

@ -475,7 +475,7 @@ fn testCommentString(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "comment-string", opts);
const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
\\pub fn main() void {}
\\pub fn main() void {}
});
const check = exe.checkObject();
@ -490,7 +490,7 @@ fn testCommentStringStaticLib(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "comment-string-static-lib", opts);
const lib = addStaticLibrary(b, opts, .{ .name = "lib", .zig_source_bytes =
\\export fn foo() void {}
\\export fn foo() void {}
});
const check = lib.checkObject();
@ -861,23 +861,23 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "emit-relocatable", opts);
const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
\\const std = @import("std");
\\extern var bar: i32;
\\export fn foo() i32 {
\\ return bar;
\\}
\\export fn printFoo() void {
\\ std.debug.print("foo={d}\n", .{foo()});
\\}
\\const std = @import("std");
\\extern var bar: i32;
\\export fn foo() i32 {
\\ return bar;
\\}
\\export fn printFoo() void {
\\ std.debug.print("foo={d}\n", .{foo()});
\\}
});
a_o.linkLibC();
const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
\\#include <stdio.h>
\\int bar = 42;
\\void printBar() {
\\ fprintf(stderr, "bar=%d\n", bar);
\\}
\\#include <stdio.h>
\\int bar = 42;
\\void printBar() {
\\ fprintf(stderr, "bar=%d\n", bar);
\\}
});
b_o.linkLibC();
@ -886,13 +886,13 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
c_o.addObject(b_o);
const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
\\const std = @import("std");
\\extern fn printFoo() void;
\\extern fn printBar() void;
\\pub fn main() void {
\\ printFoo();
\\ printBar();
\\}
\\const std = @import("std");
\\extern fn printFoo() void;
\\extern fn printBar() void;
\\pub fn main() void {
\\ printFoo();
\\ printBar();
\\}
});
exe.addObject(c_o);
exe.linkLibC();
@ -1920,8 +1920,8 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
g_o.linkLibC();
const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes =
\\#include <stdio.h>
\\__attribute__((destructor)) void fini2() { printf("8"); }
\\#include <stdio.h>
\\__attribute__((destructor)) void fini2() { printf("8"); }
});
h_o.linkLibC();
@ -2495,23 +2495,23 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "merge-strings2", opts);
const obj1 = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
\\const std = @import("std");
\\export fn foo() void {
\\ var arr: [5:0]u16 = [_:0]u16{ 1, 2, 3, 4, 5 };
\\ const slice = std.mem.sliceTo(&arr, 3);
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
\\}
\\const std = @import("std");
\\export fn foo() void {
\\ var arr: [5:0]u16 = [_:0]u16{ 1, 2, 3, 4, 5 };
\\ const slice = std.mem.sliceTo(&arr, 3);
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
\\}
});
const obj2 = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
\\const std = @import("std");
\\extern fn foo() void;
\\pub fn main() void {
\\ foo();
\\ var arr: [5:0]u16 = [_:0]u16{ 5, 4, 3, 2, 1 };
\\ const slice = std.mem.sliceTo(&arr, 3);
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
\\}
\\const std = @import("std");
\\extern fn foo() void;
\\pub fn main() void {
\\ foo();
\\ var arr: [5:0]u16 = [_:0]u16{ 5, 4, 3, 2, 1 };
\\ const slice = std.mem.sliceTo(&arr, 3);
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
\\}
});
{
@ -2752,17 +2752,17 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
});
obj2.linkLibCpp();
const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes =
\\#include <iostream>
\\#include <stdexcept>
\\extern int try_again();
\\int main() {
\\ try {
\\ try_again();
\\ } catch (const std::exception &e) {
\\ std::cout << "exception=" << e.what();
\\ }
\\ return 0;
\\}
\\#include <iostream>
\\#include <stdexcept>
\\extern int try_again();
\\int main() {
\\ try {
\\ try_again();
\\ } catch (const std::exception &e) {
\\ std::cout << "exception=" << e.what();
\\ }
\\ return 0;
\\}
});
obj3.linkLibCpp();
@ -2864,15 +2864,15 @@ fn testRelocatableMergeStrings(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "relocatable-merge-strings", opts);
const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
\\.section .rodata.str1.1,"aMS",@progbits,1
\\val1:
\\.ascii "Hello \0"
\\.section .rodata.str1.1,"aMS",@progbits,1
\\val5:
\\.ascii "World \0"
\\.section .rodata.str1.1,"aMS",@progbits,1
\\val7:
\\.ascii "Hello \0"
\\.section .rodata.str1.1,"aMS",@progbits,1
\\val1:
\\.ascii "Hello \0"
\\.section .rodata.str1.1,"aMS",@progbits,1
\\val5:
\\.ascii "World \0"
\\.section .rodata.str1.1,"aMS",@progbits,1
\\val7:
\\.ascii "Hello \0"
});
const obj2 = addObject(b, opts, .{ .name = "b" });
@ -3030,18 +3030,18 @@ fn testThunks(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "thunks", opts);
const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
\\void foo();
\\__attribute__((section(".bar"))) void bar() {
\\ return foo();
\\}
\\__attribute__((section(".foo"))) void foo() {
\\ return bar();
\\}
\\int main() {
\\ foo();
\\ bar();
\\ return 0;
\\}
\\void foo();
\\__attribute__((section(".bar"))) void bar() {
\\ return foo();
\\}
\\__attribute__((section(".foo"))) void foo() {
\\ return bar();
\\}
\\int main() {
\\ foo();
\\ bar();
\\ return 0;
\\}
});
const check = exe.checkObject();

File diff suppressed because it is too large Load diff

View file

@ -203,7 +203,7 @@ fn printOutput(
if (mem.startsWith(u8, triple, "wasm32") or
mem.startsWith(u8, triple, "riscv64-linux") or
(mem.startsWith(u8, triple, "x86_64-linux") and
builtin.os.tag != .linux or builtin.cpu.arch != .x86_64))
builtin.os.tag != .linux or builtin.cpu.arch != .x86_64))
{
// skip execution
break :code_block;

View file

@ -99,8 +99,8 @@ pub fn main() anyerror!void {
const version = Version.parse(parsed_json.value.DefaultProperties.MACOSX_DEPLOYMENT_TARGET) orelse
fatal("don't know how to parse SDK version: {s}", .{
parsed_json.value.DefaultProperties.MACOSX_DEPLOYMENT_TARGET,
});
parsed_json.value.DefaultProperties.MACOSX_DEPLOYMENT_TARGET,
});
const os_ver: OsVer = switch (version.major) {
10 => .catalina,
11 => .big_sur,

View file

@ -761,7 +761,7 @@ pub fn main() anyerror!void {
if ((std.mem.startsWith(u8, name, "mno-") and
llvm_to_zig_cpu_features.contains(name["mno-".len..])) or
(std.mem.startsWith(u8, name, "m") and
llvm_to_zig_cpu_features.contains(name["m".len..])))
llvm_to_zig_cpu_features.contains(name["m".len..])))
{
try stdout.print("m(\"{s}\"),\n", .{name});
} else {