diff options
author | François Bobot <francois.bobot@cea.fr> | 2015-12-23 22:40:21 +0100 |
---|---|---|
committer | Nicolás Ojeda Bär <n.oje.bar@gmail.com> | 2018-07-25 17:58:32 +0200 |
commit | da3f9f34f50cf8b77385d5b7a9504e77a73497cd (patch) | |
tree | bc6e26f0f57beb8e7c3277bbce6f76cfde7adc41 /driver/optcompile.ml | |
parent | 429f42d64b5674f22cbddd441d88df539128f38c (diff) | |
download | ocaml-da3f9f34f50cf8b77385d5b7a9504e77a73497cd.tar.gz |
Use reraise_raw_backtrace in Misc.try_finally
And add labels ~always for previous cleanup function and
~exceptionally for new cleanup function in exceptional case
Diffstat (limited to 'driver/optcompile.ml')
-rw-r--r-- | driver/optcompile.ml | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/driver/optcompile.ml b/driver/optcompile.ml index a653f23b9e..7fbe1e62dc 100644 --- a/driver/optcompile.ml +++ b/driver/optcompile.ml @@ -135,13 +135,11 @@ let implementation ~backend ppf sourcefile outputprefix = Compilenv.save_unit_info cmxfile) end end; - Warnings.check_fatal (); - Stypes.dump (Some (outputprefix ^ ".annot")) + Warnings.check_fatal () in - try comp (Pparse.parse_implementation ~tool_name sourcefile) - with x -> - Stypes.dump (Some (outputprefix ^ ".annot")); - remove_file objfile; - remove_file cmxfile; - raise x + Misc.try_finally (fun () -> + comp (Pparse.parse_implementation ~tool_name sourcefile) + ) + ~always:(fun () -> Stypes.dump (Some (outputprefix ^ ".annot"))) + ~exceptionally:(fun () -> remove_file objfile; remove_file cmxfile) ) |