| ... | @@ -2300,7 +2300,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { | ... | @@ -2300,7 +2300,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { |
| 2300 | zcu.intern_pool.dumpGenericInstances(gpa); | 2300 | zcu.intern_pool.dumpGenericInstances(gpa); |
| 2301 | } | 2301 | } |
| 2302 | | 2302 | |
| 2303 | if (comp.config.is_test and try comp.totalErrorCount() == 0) { | 2303 | if (comp.config.is_test) { |
| 2304 | // The `test_functions` decl has been intentionally postponed until now, | 2304 | // The `test_functions` decl has been intentionally postponed until now, |
| 2305 | // at which point we must populate it with the list of test functions that | 2305 | // at which point we must populate it with the list of test functions that |
| 2306 | // have been discovered and not filtered out. | 2306 | // have been discovered and not filtered out. |
| ... | @@ -2394,6 +2394,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { | ... | @@ -2394,6 +2394,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { |
| 2394 | } | 2394 | } |
| 2395 | | 2395 | |
| 2396 | try flush(comp, arena, .main, main_progress_node); | 2396 | try flush(comp, arena, .main, main_progress_node); |
| | 2397 | |
| 2397 | if (try comp.totalErrorCount() != 0) return; | 2398 | if (try comp.totalErrorCount() != 0) return; |
| 2398 | | 2399 | |
| 2399 | // Failure here only means an unnecessary cache miss. | 2400 | // Failure here only means an unnecessary cache miss. |
| ... | @@ -2411,7 +2412,6 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { | ... | @@ -2411,7 +2412,6 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { |
| 2411 | }, | 2412 | }, |
| 2412 | .incremental => { | 2413 | .incremental => { |
| 2413 | try flush(comp, arena, .main, main_progress_node); | 2414 | try flush(comp, arena, .main, main_progress_node); |
| 2414 | if (try comp.totalErrorCount() != 0) return; | | |
| 2415 | }, | 2415 | }, |
| 2416 | } | 2416 | } |
| 2417 | } | 2417 | } |
| ... | @@ -3047,93 +3047,6 @@ fn addBuf(list: *std.ArrayList(std.posix.iovec_const), buf: []const u8) void { | ... | @@ -3047,93 +3047,6 @@ fn addBuf(list: *std.ArrayList(std.posix.iovec_const), buf: []const u8) void { |
| 3047 | list.appendAssumeCapacity(.{ .base = buf.ptr, .len = buf.len }); | 3047 | list.appendAssumeCapacity(.{ .base = buf.ptr, .len = buf.len }); |
| 3048 | } | 3048 | } |
| 3049 | | 3049 | |
| 3050 | /// This function is temporally single-threaded. | | |
| 3051 | pub fn totalErrorCount(comp: *Compilation) Allocator.Error!u32 { | | |
| 3052 | var total: usize = | | |
| 3053 | comp.misc_failures.count() + | | |
| 3054 | @intFromBool(comp.alloc_failure_occurred) + | | |
| 3055 | comp.lld_errors.items.len; | | |
| 3056 | | | |
| 3057 | for (comp.failed_c_objects.values()) |bundle| { | | |
| 3058 | total += bundle.diags.len; | | |
| 3059 | } | | |
| 3060 | | | |
| 3061 | for (comp.failed_win32_resources.values()) |errs| { | | |
| 3062 | total += errs.errorMessageCount(); | | |
| 3063 | } | | |
| 3064 | | | |
| 3065 | if (comp.module) |zcu| { | | |
| 3066 | const ip = &zcu.intern_pool; | | |
| 3067 | | | |
| 3068 | var all_references: ?std.AutoHashMapUnmanaged(InternPool.AnalUnit, ?Zcu.ResolvedReference) = null; | | |
| 3069 | defer if (all_references) |*a| a.deinit(zcu.gpa); | | |
| 3070 | | | |
| 3071 | total += zcu.failed_exports.count(); | | |
| 3072 | total += zcu.failed_embed_files.count(); | | |
| 3073 | | | |
| 3074 | for (zcu.failed_files.keys(), zcu.failed_files.values()) |file, error_msg| { | | |
| 3075 | if (error_msg) |_| { | | |
| 3076 | total += 1; | | |
| 3077 | } else { | | |
| 3078 | assert(file.zir_loaded); | | |
| 3079 | const payload_index = file.zir.extra[@intFromEnum(Zir.ExtraIndex.compile_errors)]; | | |
| 3080 | assert(payload_index != 0); | | |
| 3081 | const header = file.zir.extraData(Zir.Inst.CompileErrors, payload_index); | | |
| 3082 | total += header.data.items_len; | | |
| 3083 | } | | |
| 3084 | } | | |
| 3085 | | | |
| 3086 | // Skip errors for Decls within files that failed parsing. | | |
| 3087 | // When a parse error is introduced, we keep all the semantic analysis for | | |
| 3088 | // the previous parse success, including compile errors, but we cannot | | |
| 3089 | // emit them until the file succeeds parsing. | | |
| 3090 | for (zcu.failed_analysis.keys()) |anal_unit| { | | |
| 3091 | if (comp.incremental) { | | |
| 3092 | if (all_references == null) { | | |
| 3093 | all_references = try zcu.resolveReferences(); | | |
| 3094 | } | | |
| 3095 | if (!all_references.?.contains(anal_unit)) continue; | | |
| 3096 | } | | |
| 3097 | const file_index = switch (anal_unit.unwrap()) { | | |
| 3098 | .cau => |cau| zcu.namespacePtr(ip.getCau(cau).namespace).file_scope, | | |
| 3099 | .func => |ip_index| (zcu.funcInfo(ip_index).zir_body_inst.resolveFull(ip) orelse continue).file, | | |
| 3100 | }; | | |
| 3101 | if (zcu.fileByIndex(file_index).okToReportErrors()) { | | |
| 3102 | total += 1; | | |
| 3103 | if (zcu.cimport_errors.get(anal_unit)) |errors| { | | |
| 3104 | total += errors.errorMessageCount(); | | |
| 3105 | } | | |
| 3106 | } | | |
| 3107 | } | | |
| 3108 | | | |
| 3109 | for (zcu.failed_codegen.keys()) |nav| { | | |
| 3110 | if (zcu.navFileScope(nav).okToReportErrors()) { | | |
| 3111 | total += 1; | | |
| 3112 | } | | |
| 3113 | } | | |
| 3114 | | | |
| 3115 | if (zcu.intern_pool.global_error_set.getNamesFromMainThread().len > zcu.error_limit) { | | |
| 3116 | total += 1; | | |
| 3117 | } | | |
| 3118 | } | | |
| 3119 | | | |
| 3120 | // The "no entry point found" error only counts if there are no semantic analysis errors. | | |
| 3121 | if (total == 0) { | | |
| 3122 | total += @intFromBool(comp.link_error_flags.no_entry_point_found); | | |
| 3123 | } | | |
| 3124 | total += @intFromBool(comp.link_error_flags.missing_libc); | | |
| 3125 | total += comp.link_errors.items.len; | | |
| 3126 | | | |
| 3127 | // Compile log errors only count if there are no other errors. | | |
| 3128 | if (total == 0) { | | |
| 3129 | if (comp.module) |zcu| { | | |
| 3130 | total += @intFromBool(zcu.compile_log_sources.count() != 0); | | |
| 3131 | } | | |
| 3132 | } | | |
| 3133 | | | |
| 3134 | return @intCast(total); | | |
| 3135 | } | | |
| 3136 | | | |
| 3137 | /// This function is temporally single-threaded. | 3050 | /// This function is temporally single-threaded. |
| 3138 | pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { | 3051 | pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { |
| 3139 | const gpa = comp.gpa; | 3052 | const gpa = comp.gpa; |
| ... | @@ -3357,8 +3270,6 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { | ... | @@ -3357,8 +3270,6 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { |
| 3357 | } | 3270 | } |
| 3358 | } | 3271 | } |
| 3359 | | 3272 | |
| 3360 | assert(try comp.totalErrorCount() == bundle.root_list.items.len); | | |
| 3361 | | | |
| 3362 | if (comp.module) |zcu| { | 3273 | if (comp.module) |zcu| { |
| 3363 | if (comp.incremental and bundle.root_list.items.len == 0) { | 3274 | if (comp.incremental and bundle.root_list.items.len == 0) { |
| 3364 | const should_have_error = for (zcu.transitive_failed_analysis.keys()) |failed_unit| { | 3275 | const should_have_error = for (zcu.transitive_failed_analysis.keys()) |failed_unit| { |
| ... | @@ -3377,6 +3288,12 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { | ... | @@ -3377,6 +3288,12 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { |
| 3377 | return bundle.toOwnedBundle(compile_log_text); | 3288 | return bundle.toOwnedBundle(compile_log_text); |
| 3378 | } | 3289 | } |
| 3379 | | 3290 | |
| | 3291 | fn totalErrorCount(comp: *Compilation) !u32 { |
| | 3292 | var errors = try comp.getAllErrorsAlloc(); |
| | 3293 | defer errors.deinit(comp.gpa); |
| | 3294 | return errors.errorMessageCount(); |
| | 3295 | } |
| | 3296 | |
| 3380 | pub const ErrorNoteHashContext = struct { | 3297 | pub const ErrorNoteHashContext = struct { |
| 3381 | eb: *const ErrorBundle.Wip, | 3298 | eb: *const ErrorBundle.Wip, |
| 3382 | | 3299 | |