From 3c5927fb87034affd6af56ecd5d9ae07fe23d690 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 14 Jul 2021 12:16:48 -0700 Subject: Sema: add a strategy for handling costly source locations Now you can pass `.unneeded` for a `LazySrcLoc` and if there ended up being a compile error that needed it, you'll get `error.NeededSourceLocation`. Callsites can now exploit this error to do the expensive computation to produce a source location object and then repeat the operation. --- src/Compilation.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index 4a442a8b67..f241ae6b10 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -148,7 +148,7 @@ emit_docs: ?EmitLoc, work_queue_wait_group: WaitGroup, astgen_wait_group: WaitGroup, -pub const InnerError = Module.InnerError; +pub const SemaError = Module.SemaError; pub const CRTFile = struct { lock: Cache.Lock, @@ -3170,7 +3170,7 @@ pub fn addCCArgs( try argv.appendSlice(comp.clang_argv); } -fn failCObj(comp: *Compilation, c_object: *CObject, comptime format: []const u8, args: anytype) InnerError { +fn failCObj(comp: *Compilation, c_object: *CObject, comptime format: []const u8, args: anytype) SemaError { @setCold(true); const err_msg = blk: { const msg = try std.fmt.allocPrint(comp.gpa, format, args); @@ -3191,7 +3191,7 @@ fn failCObjWithOwnedErrorMsg( comp: *Compilation, c_object: *CObject, err_msg: *CObject.ErrorMsg, -) InnerError { +) SemaError { @setCold(true); { const lock = comp.mutex.acquire(); -- cgit v1.2.3