diff options
| author | Veikka Tuominen <git@vexu.eu> | 2023-01-24 13:35:10 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-10-21 12:36:29 +0300 |
| commit | bf61c5c0656e3b2198fb009fe5cc59f55263ceae (patch) | |
| tree | d72d4f475af2d6ba6cbc4080ecb6e8b0d7a24c3d /src/Compilation.zig | |
| parent | 3d6e63337164b42fec4df55687071be38d33dce9 (diff) | |
| download | zig-bf61c5c0656e3b2198fb009fe5cc59f55263ceae.tar.gz zig-bf61c5c0656e3b2198fb009fe5cc59f55263ceae.zip | |
make distinct error limit configurable
Closes #786
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 800c8288d0..e15ade5d5b 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -739,6 +739,7 @@ pub const InitOptions = struct { pdb_source_path: ?[]const u8 = null, /// (Windows) PDB output path pdb_out_path: ?[]const u8 = null, + error_limit: ?Module.ErrorInt = null, }; fn addModuleTableToCacheHash( @@ -1432,6 +1433,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { .local_zir_cache = local_zir_cache, .emit_h = emit_h, .tmp_hack_arena = std.heap.ArenaAllocator.init(gpa), + .error_limit = options.error_limit orelse (std.math.maxInt(u16) - 1), }; try module.init(); @@ -2486,6 +2488,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes man.hash.add(comp.bin_file.options.skip_linker_dependencies); man.hash.add(comp.bin_file.options.parent_compilation_link_libc); man.hash.add(mod.emit_h != null); + man.hash.add(mod.error_limit); } try man.addOptionalFile(comp.bin_file.options.linker_script); @@ -2866,6 +2869,10 @@ pub fn totalErrorCount(self: *Compilation) u32 { } } } + + if (module.global_error_set.entries.len - 1 > module.error_limit) { + total += 1; + } } // The "no entry point found" error only counts if there are no semantic analysis errors. @@ -3016,6 +3023,22 @@ pub fn getAllErrorsAlloc(self: *Compilation) !ErrorBundle { for (module.failed_exports.values()) |value| { try addModuleErrorMsg(module, &bundle, value.*); } + + const actual_error_count = module.global_error_set.entries.len - 1; + if (actual_error_count > module.error_limit) { + try bundle.addRootErrorMessage(.{ + .msg = try bundle.printString("module used more errors than possible: used {d}, max {d}", .{ + actual_error_count, module.error_limit, + }), + .notes_len = 1, + }); + const notes_start = try bundle.reserveNotes(1); + bundle.extra.items[notes_start] = @intFromEnum(try bundle.addErrorMessage(.{ + .msg = try bundle.printString("use '--error-limit {d}' to increase limit", .{ + actual_error_count, + }), + })); + } } if (bundle.root_list.items.len == 0) { |
