aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-10-23 03:19:03 -0400
committerGitHub <noreply@github.com>2023-10-23 03:19:03 -0400
commit94d61ce964cd23fcf46dabeddc19837b4dd3209f (patch)
tree00fc6af0a362d7d5744744e3f5e8008136957401 /src/Compilation.zig
parentb82459fa435c366c6af0fee96c3d9b95c24078f9 (diff)
parented82e4f7ac057286444135dda79fb7c6a579573a (diff)
downloadzig-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/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 70d0e5ff82..1d54456f6b 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) {