diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-10-23 03:19:03 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-23 03:19:03 -0400 |
| commit | 94d61ce964cd23fcf46dabeddc19837b4dd3209f (patch) | |
| tree | 00fc6af0a362d7d5744744e3f5e8008136957401 /src/Module.zig | |
| parent | b82459fa435c366c6af0fee96c3d9b95c24078f9 (diff) | |
| parent | ed82e4f7ac057286444135dda79fb7c6a579573a (diff) | |
| download | zig-94d61ce964cd23fcf46dabeddc19837b4dd3209f.tar.gz zig-94d61ce964cd23fcf46dabeddc19837b4dd3209f.zip | |
Merge pull request #17651 from Vexu/error-limit
Make distinct error limit configurable (attempt #2)
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig index 41f4ec2b41..c6a28caab4 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -137,6 +137,9 @@ deletion_set: std.AutoArrayHashMapUnmanaged(Decl.Index, void) = .{}, /// Key is the error name, index is the error tag value. Index 0 has a length-0 string. global_error_set: GlobalErrorSet = .{}, +/// Maximum amount of distinct error values, set by --error-limit +error_limit: ErrorInt, + /// Incrementing integer used to compare against the corresponding Decl /// field to determine whether a Decl's status applies to an ongoing update, or a /// previous analysis. @@ -5020,6 +5023,11 @@ pub fn getErrorValueFromSlice( return getErrorValue(mod, interned_name); } +pub fn errorSetBits(mod: *Module) u16 { + if (mod.error_limit == 0) return 0; + return std.math.log2_int_ceil(ErrorInt, mod.error_limit + 1); // +1 for no error +} + pub fn createAnonymousDecl(mod: *Module, block: *Sema.Block, typed_value: TypedValue) !Decl.Index { const src_decl = mod.declPtr(block.src_decl); return mod.createAnonymousDeclFromDecl(src_decl, block.namespace, block.wip_capture_scope, typed_value); @@ -5898,6 +5906,10 @@ pub fn intType(mod: *Module, signedness: std.builtin.Signedness, bits: u16) Allo } })).toType(); } +pub fn errorIntType(mod: *Module) std.mem.Allocator.Error!Type { + return mod.intType(.unsigned, mod.errorSetBits()); +} + pub fn arrayType(mod: *Module, info: InternPool.Key.ArrayType) Allocator.Error!Type { const i = try intern(mod, .{ .array_type = info }); return i.toType(); |
