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