Skip to content

Commit

Permalink
fix memory errors related to astgen_analyser
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Sep 10, 2023
1 parent 5ab9cd8 commit ccd24ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
11 changes: 0 additions & 11 deletions src/DocumentStore.zig
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,6 @@ pub fn refreshDocument(self: *DocumentStore, uri: Uri, new_text: [:0]const u8) !
const new_import_count = handle.import_uris.items.len;
const new_cimport_count = handle.cimports.len;

if (handle.root_decl.unwrap()) |decl_index| {
self.mod.?.destroyDecl(decl_index);
handle.root_decl = .none;
}
if (self.config.analysis_backend == .astgen_analyser and
handle.zir_status == .done and // TODO support oudated
!handle.zir.hasCompileErrors())
{
try self.mod.?.semaFile(handle);
}

if (old_import_count != new_import_count or
old_cimport_count != new_cimport_count)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,9 @@ pub fn updateConfiguration(server: *Server, new_config: configuration.Configurat
if (new_zig_exe_path or new_zig_lib_path) {
server.document_store.cimports.clearAndFree(server.document_store.allocator);
}

if (server.config.analysis_backend == .astgen_analyser) {

if (server.config.analysis_backend == .astgen_analyser) blk: {
if (server.mod != null) break :blk;
server.mod = Module.init(server.allocator, &server.ip, &server.document_store);
server.document_store.mod = &server.mod.?;
} else if (server.mod) |*mod| {
Expand All @@ -887,7 +888,6 @@ pub fn updateConfiguration(server: *Server, new_config: configuration.Configurat
server.allocator.free(json_message);
}


// <---------------------------------------------------------->
// don't modify config options after here, only show messages
// <---------------------------------------------------------->
Expand Down

0 comments on commit ccd24ed

Please sign in to comment.