llvm.org GIT mirror llvm / d27b926
Finish removing DestroySource. Fixes pr21901. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224782 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 5 years ago
7 changed file(s) with 10 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
1919 import "C"
2020 import "errors"
2121
22 type LinkerMode C.LLVMLinkerMode
23
24 const (
25 LinkerDestroySource = C.LLVMLinkerDestroySource
26 LinkerPreserveSource = C.LLVMLinkerPreserveSource
27 )
28
29 func LinkModules(Dest, Src Module, Mode LinkerMode) error {
22 func LinkModules(Dest, Src Module) error {
3023 var cmsg *C.char
31 failed := C.LLVMLinkModules(Dest.C, Src.C, C.LLVMLinkerMode(Mode), &cmsg)
24 failed := C.LLVMLinkModules(Dest.C, Src.C, 0, &cmsg)
3225 if failed != 0 {
3326 err := errors.New(C.GoString(cmsg))
3427 C.LLVMDisposeMessage(cmsg)
2222
2323 void llvm_raise(value Prototype, char *Message);
2424
25 /* llmodule -> llmodule -> Mode.t -> unit */
26 CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src, value Mode) {
25 /* llmodule -> llmodule -> unit */
26 CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src) {
2727 char* Message;
2828
29 if (LLVMLinkModules(Dst, Src, Int_val(Mode), &Message))
29 if (LLVMLinkModules(Dst, Src, 0, &Message))
3030 llvm_raise(*caml_named_value("Llvm_linker.Error"), Message);
3131
3232 return Val_unit;
1010
1111 let () = Callback.register_exception "Llvm_linker.Error" (Error "")
1212
13 module Mode = struct
14 type t =
15 | DestroySource
16 | PreserveSource
17 end
18
19 external link_modules : Llvm.llmodule -> Llvm.llmodule -> Mode.t -> unit
13 external link_modules : Llvm.llmodule -> Llvm.llmodule -> unit
2014 = "llvm_link_modules"
1313
1414 exception Error of string
1515
16 (** Linking mode. *)
17 module Mode : sig
18 type t =
19 | DestroySource
20 | PreserveSource
21 end
22
2316 (** [link_modules dst src mode] links [src] into [dst], raising [Error]
2417 if the linking fails. *)
25 val link_modules : Llvm.llmodule -> Llvm.llmodule -> Mode.t -> unit
18 val link_modules : Llvm.llmodule -> Llvm.llmodule -> unit
1919 extern "C" {
2020 #endif
2121
22
23 typedef enum {
24 LLVMLinkerDestroySource = 0, /* Allow source module to be destroyed. */
25 LLVMLinkerPreserveSource = 1 /* Preserve the source module. */
26 } LLVMLinkerMode;
27
28
2922 /* Links the source module into the destination module, taking ownership
3023 * of the source module away from the caller. Optionally returns a
3124 * human-readable description of any errors that occurred in linking.
3225 * OutMessage must be disposed with LLVMDisposeMessage. The return value
3326 * is true if an error occurred, false otherwise. */
3427 LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src,
35 LLVMLinkerMode Mode, char **OutMessage);
28 unsigned Unused, char **OutMessage);
3629
3730 #ifdef __cplusplus
3831 }
17381738 //===----------------------------------------------------------------------===//
17391739
17401740 LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src,
1741 LLVMLinkerMode Mode, char **OutMessages) {
1741 unsigned Unused, char **OutMessages) {
17421742 Module *D = unwrap(Dest);
17431743 std::string Message;
17441744 raw_string_ostream Stream(Message);
4444
4545 let m1 = make_module "one"
4646 and m2 = make_module "two" in
47 link_modules m1 m2 Mode.DestroySource;
47 link_modules m1 m2;
4848 dispose_module m1;
4949
5050 let m1 = make_module "one"