| ... | ... | @@ -3065,8 +3065,8 @@ pub fn totalErrorCount(comp: *Compilation) Allocator.Error!u32 { |
| 3065 | 3065 | if (comp.module) |zcu| { |
| 3066 | 3066 | const ip = &zcu.intern_pool; |
| 3067 | 3067 | |
| 3068 | | var all_references = try zcu.resolveReferences(); |
| 3069 | | defer all_references.deinit(zcu.gpa); |
| 3068 | var all_references: ?std.AutoHashMapUnmanaged(InternPool.AnalUnit, ?Zcu.ResolvedReference) = null; |
| 3069 | defer if (all_references) |*a| a.deinit(zcu.gpa); |
| 3070 | 3070 | |
| 3071 | 3071 | total += zcu.failed_exports.count(); |
| 3072 | 3072 | total += zcu.failed_embed_files.count(); |
| ... | ... | @@ -3088,7 +3088,12 @@ pub fn totalErrorCount(comp: *Compilation) Allocator.Error!u32 { |
| 3088 | 3088 | // the previous parse success, including compile errors, but we cannot |
| 3089 | 3089 | // emit them until the file succeeds parsing. |
| 3090 | 3090 | for (zcu.failed_analysis.keys()) |anal_unit| { |
| 3091 | | if (comp.incremental and !all_references.contains(anal_unit)) continue; |
| 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 | } |
| 3092 | 3097 | const file_index = switch (anal_unit.unwrap()) { |
| 3093 | 3098 | .cau => |cau| zcu.namespacePtr(ip.getCau(cau).namespace).file_scope, |
| 3094 | 3099 | .func => |ip_index| (zcu.funcInfo(ip_index).zir_body_inst.resolveFull(ip) orelse continue).file, |
| ... | ... | @@ -3172,8 +3177,8 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { |
| 3172 | 3177 | }); |
| 3173 | 3178 | } |
| 3174 | 3179 | |
| 3175 | | var all_references = if (comp.module) |zcu| try zcu.resolveReferences() else undefined; |
| 3176 | | defer if (comp.module != null) all_references.deinit(gpa); |
| 3180 | var all_references: ?std.AutoHashMapUnmanaged(InternPool.AnalUnit, ?Zcu.ResolvedReference) = null; |
| 3181 | defer if (all_references) |*a| a.deinit(gpa); |
| 3177 | 3182 | |
| 3178 | 3183 | if (comp.module) |zcu| { |
| 3179 | 3184 | const ip = &zcu.intern_pool; |
| ... | ... | @@ -3231,7 +3236,12 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { |
| 3231 | 3236 | if (err) |e| return e; |
| 3232 | 3237 | } |
| 3233 | 3238 | for (zcu.failed_analysis.keys(), zcu.failed_analysis.values()) |anal_unit, error_msg| { |
| 3234 | | if (comp.incremental and !all_references.contains(anal_unit)) continue; |
| 3239 | if (comp.incremental) { |
| 3240 | if (all_references == null) { |
| 3241 | all_references = try zcu.resolveReferences(); |
| 3242 | } |
| 3243 | if (!all_references.?.contains(anal_unit)) continue; |
| 3244 | } |
| 3235 | 3245 | |
| 3236 | 3246 | const file_index = switch (anal_unit.unwrap()) { |
| 3237 | 3247 | .cau => |cau| zcu.namespacePtr(ip.getCau(cau).namespace).file_scope, |
| ... | ... | @@ -3352,7 +3362,10 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle { |
| 3352 | 3362 | if (comp.module) |zcu| { |
| 3353 | 3363 | if (comp.incremental and bundle.root_list.items.len == 0) { |
| 3354 | 3364 | const should_have_error = for (zcu.transitive_failed_analysis.keys()) |failed_unit| { |
| 3355 | | if (all_references.contains(failed_unit)) break true; |
| 3365 | if (all_references == null) { |
| 3366 | all_references = try zcu.resolveReferences(); |
| 3367 | } |
| 3368 | if (all_references.?.contains(failed_unit)) break true; |
| 3356 | 3369 | } else false; |
| 3357 | 3370 | if (should_have_error) { |
| 3358 | 3371 | @panic("referenced transitive analysis errors, but none actually emitted"); |
| ... | ... | @@ -3414,7 +3427,7 @@ pub fn addModuleErrorMsg( |
| 3414 | 3427 | mod: *Zcu, |
| 3415 | 3428 | eb: *ErrorBundle.Wip, |
| 3416 | 3429 | module_err_msg: Zcu.ErrorMsg, |
| 3417 | | all_references: *const std.AutoHashMapUnmanaged(InternPool.AnalUnit, ?Zcu.ResolvedReference), |
| 3430 | all_references: *?std.AutoHashMapUnmanaged(InternPool.AnalUnit, ?Zcu.ResolvedReference), |
| 3418 | 3431 | ) !void { |
| 3419 | 3432 | const gpa = eb.gpa; |
| 3420 | 3433 | const ip = &mod.intern_pool; |
| ... | ... | @@ -3438,13 +3451,17 @@ pub fn addModuleErrorMsg( |
| 3438 | 3451 | defer ref_traces.deinit(gpa); |
| 3439 | 3452 | |
| 3440 | 3453 | if (module_err_msg.reference_trace_root.unwrap()) |rt_root| { |
| 3454 | if (all_references.* == null) { |
| 3455 | all_references.* = try mod.resolveReferences(); |
| 3456 | } |
| 3457 | |
| 3441 | 3458 | var seen: std.AutoHashMapUnmanaged(InternPool.AnalUnit, void) = .{}; |
| 3442 | 3459 | defer seen.deinit(gpa); |
| 3443 | 3460 | |
| 3444 | 3461 | const max_references = mod.comp.reference_trace orelse Sema.default_reference_trace_len; |
| 3445 | 3462 | |
| 3446 | 3463 | var referenced_by = rt_root; |
| 3447 | | while (all_references.get(referenced_by)) |maybe_ref| { |
| 3464 | while (all_references.*.?.get(referenced_by)) |maybe_ref| { |
| 3448 | 3465 | const ref = maybe_ref orelse break; |
| 3449 | 3466 | const gop = try seen.getOrPut(gpa, ref.referencer); |
| 3450 | 3467 | if (gop.found_existing) break; |