aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-01-24 13:35:10 +0200
committerAndrew Kelley <andrew@ziglang.org>2023-10-16 04:08:45 -0400
commit78855bd21866b515018259a2194e036e4b3120df (patch)
tree9d5df7cd0e5d909163475a5bdb30c94794460321 /src/Compilation.zig
parentfbd90e487b4abe32422dc997467b1d81ad574d5d (diff)
downloadzig-78855bd21866b515018259a2194e036e4b3120df.tar.gz
zig-78855bd21866b515018259a2194e036e4b3120df.zip
make distinct error limit configurable
Closes #786
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 57cc81f8b7..3eec2a6e94 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(
@@ -1418,6 +1419,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();
@@ -2472,6 +2474,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);
@@ -2852,6 +2855,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.
@@ -3002,6 +3009,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) {