Function toAttribute [src]

Prototype

pub fn toAttribute(self: Index, builder: *const Builder) Attribute

Parameters

self: Indexbuilder: *const Builder

Source

pub fn toAttribute(self: Index, builder: *const Builder) Attribute { @setEvalBranchQuota(2_000); const storage = self.toStorage(builder); if (storage.kind.toString()) |kind| return .{ .string = .{ .kind = kind, .value = @enumFromInt(storage.value), } } else return switch (storage.kind) { inline .zeroext, .signext, .inreg, .byval, .byref, .preallocated, .inalloca, .sret, .elementtype, .@"align", .@"noalias", .nocapture, .nofree, .nest, .returned, .nonnull, .dereferenceable, .dereferenceable_or_null, .swiftself, .swiftasync, .swifterror, .immarg, .noundef, .nofpclass, .alignstack, .allocalign, .allocptr, .readnone, .readonly, .writeonly, //.alignstack, .allockind, .allocsize, .alwaysinline, .builtin, .cold, .convergent, .disable_sanitizer_information, .fn_ret_thunk_extern, .hot, .inlinehint, .jumptable, .memory, .minsize, .naked, .nobuiltin, .nocallback, .noduplicate, //.nofree, .noimplicitfloat, .@"noinline", .nomerge, .nonlazybind, .noprofile, .skipprofile, .noredzone, .noreturn, .norecurse, .willreturn, .nosync, .nounwind, .nosanitize_bounds, .nosanitize_coverage, .null_pointer_is_valid, .optforfuzzing, .optnone, .optsize, //.preallocated, .returns_twice, .safestack, .sanitize_address, .sanitize_memory, .sanitize_thread, .sanitize_hwaddress, .sanitize_memtag, .speculative_load_hardening, .speculatable, .ssp, .sspstrong, .sspreq, .strictfp, .uwtable, .nocf_check, .shadowcallstack, .mustprogress, .vscale_range, .no_sanitize_address, .no_sanitize_hwaddress, .sanitize_address_dyninit, => |kind| { const field = comptime blk: { @setEvalBranchQuota(10_000); for (@typeInfo(Attribute).@"union".fields) |field| { if (std.mem.eql(u8, field.name, @tagName(kind))) break :blk field; } unreachable; }; comptime assert(std.mem.eql(u8, @tagName(kind), field.name)); return @unionInit(Attribute, field.name, switch (field.type) { void => {}, u32 => storage.value, Alignment, String, Type, UwTable => @enumFromInt(storage.value), AllocKind, AllocSize, FpClass, Memory, VScaleRange => @bitCast(storage.value), else => @compileError("bad payload type: " ++ field.name ++ ": " ++ @typeName(field.type)), }); }, .string, .none => unreachable, _ => unreachable, }; }