DoxigAlpha

format

Function parameters

Parameters

#
w:*Writer

Type definitions in this namespace

Types

#

Functions in this namespace

Functions

#

= 16

Values

#

Source

Implementation

#
fn format(data: FormatData, w: *Writer) Writer.Error!void {
    const attribute = data.attribute_index.toAttribute(data.builder);
    switch (attribute) {
        .zeroext,
        .signext,
        .inreg,
        .@"noalias",
        .nocapture,
        .nofree,
        .nest,
        .returned,
        .nonnull,
        .swiftself,
        .swiftasync,
        .swifterror,
        .immarg,
        .noundef,
        .allocalign,
        .allocptr,
        .readnone,
        .readonly,
        .writeonly,
        .alwaysinline,
        .builtin,
        .cold,
        .convergent,
        .disable_sanitizer_information,
        .fn_ret_thunk_extern,
        .hot,
        .inlinehint,
        .jumptable,
        .minsize,
        .naked,
        .nobuiltin,
        .nocallback,
        .noduplicate,
        .noimplicitfloat,
        .@"noinline",
        .nomerge,
        .nonlazybind,
        .noprofile,
        .skipprofile,
        .noredzone,
        .noreturn,
        .norecurse,
        .willreturn,
        .nosync,
        .nounwind,
        .nosanitize_bounds,
        .nosanitize_coverage,
        .null_pointer_is_valid,
        .optforfuzzing,
        .optnone,
        .optsize,
        .returns_twice,
        .safestack,
        .sanitize_address,
        .sanitize_memory,
        .sanitize_thread,
        .sanitize_hwaddress,
        .sanitize_memtag,
        .speculative_load_hardening,
        .speculatable,
        .ssp,
        .sspstrong,
        .sspreq,
        .strictfp,
        .nocf_check,
        .shadowcallstack,
        .mustprogress,
        .no_sanitize_address,
        .no_sanitize_hwaddress,
        .sanitize_address_dyninit,
        => try w.print(" {s}", .{@tagName(attribute)}),
        .byval,
        .byref,
        .preallocated,
        .inalloca,
        .sret,
        .elementtype,
        => |ty| try w.print(" {s}({f})", .{ @tagName(attribute), ty.fmt(data.builder, .percent) }),
        .@"align" => |alignment| try w.print("{f}", .{alignment.fmt(" ")}),
        .dereferenceable,
        .dereferenceable_or_null,
        => |size| try w.print(" {s}({d})", .{ @tagName(attribute), size }),
        .nofpclass => |fpclass| {
            const Int = @typeInfo(FpClass).@"struct".backing_integer.?;
            try w.print(" {s}(", .{@tagName(attribute)});
            var any = false;
            var remaining: Int = @bitCast(fpclass);
            inline for (@typeInfo(FpClass).@"struct".decls) |decl| {
                const pattern: Int = @bitCast(@field(FpClass, decl.name));
                if (remaining & pattern == pattern) {
                    if (!any) {
                        try w.writeByte(' ');
                        any = true;
                    }
                    try w.writeAll(decl.name);
                    remaining &= ~pattern;
                }
            }
            try w.writeByte(')');
        },
        .alignstack => |alignment| {
            try w.print(" {t}", .{attribute});
            const alignment_bytes = alignment.toByteUnits() orelse return;
            if (data.flags.pound) {
                try w.print("={d}", .{alignment_bytes});
            } else {
                try w.print("({d})", .{alignment_bytes});
            }
        },
        .allockind => |allockind| {
            try w.print(" {t}(\"", .{attribute});
            var any = false;
            inline for (@typeInfo(AllocKind).@"struct".fields) |field| {
                if (comptime std.mem.eql(u8, field.name, "_")) continue;
                if (@field(allockind, field.name)) {
                    if (!any) {
                        try w.writeByte(',');
                        any = true;
                    }
                    try w.writeAll(field.name);
                }
            }
            try w.writeAll("\")");
        },
        .allocsize => |allocsize| {
            try w.print(" {t}({d}", .{ attribute, allocsize.elem_size });
            if (allocsize.num_elems != AllocSize.none)
                try w.print(",{d}", .{allocsize.num_elems});
            try w.writeByte(')');
        },
        .memory => |memory| {
            try w.print(" {t}(", .{attribute});
            var any = memory.other != .none or
                (memory.argmem == .none and memory.inaccessiblemem == .none);
            if (any) try w.writeAll(@tagName(memory.other));
            inline for (.{ "argmem", "inaccessiblemem" }) |kind| {
                if (@field(memory, kind) != memory.other) {
                    if (any) try w.writeAll(", ");
                    try w.print("{s}: {s}", .{ kind, @tagName(@field(memory, kind)) });
                    any = true;
                }
            }
            try w.writeByte(')');
        },
        .uwtable => |uwtable| if (uwtable != .none) {
            try w.print(" {s}", .{@tagName(attribute)});
            if (uwtable != UwTable.default) try w.print("({s})", .{@tagName(uwtable)});
        },
        .vscale_range => |vscale_range| try w.print(" {s}({d},{d})", .{
            @tagName(attribute),
            vscale_range.min.toByteUnits().?,
            vscale_range.max.toByteUnits() orelse 0,
        }),
        .string => |string_attr| if (data.flags.quote) {
            try w.print(" {f}", .{string_attr.kind.fmtQ(data.builder)});
            if (string_attr.value != .empty)
                try w.print("={f}", .{string_attr.value.fmtQ(data.builder)});
        },
        .none => unreachable,
    }
}