llvm.org GIT mirror llvm / f4430ca
[OCaml] Use LLVMCreateMessage with constant strings when calling llvm_raise The llvm_string_of_message function, called by llvm_raise, calls LLVMDisposeMessage, which expects the message to be dynamically allocated; it fails freeing the message otherwise. So always dynamically allocate with LLVMCreateMessage. Differential Revision: http://reviews.llvm.org/D18675 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265116 91177308-0d34-0410-b5e6-96231b3b80d8 Jeroen Ketema 3 years ago
4 changed file(s) with 7 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1414 |* *|
1515 \*===----------------------------------------------------------------------===*/
1616
17 #include "llvm-c/Analysis.h"
1718 #include "llvm-c/Core.h"
18 #include "llvm-c/Analysis.h"
1919 #include "caml/alloc.h"
2020 #include "caml/mlvalues.h"
2121 #include "caml/memory.h"
1212 \*===----------------------------------------------------------------------===*/
1313
1414 #include "llvm-c/BitReader.h"
15 #include "llvm-c/Core.h"
1516 #include "caml/alloc.h"
1617 #include "caml/fail.h"
1718 #include "caml/memory.h"
2425 LLVMModuleRef M;
2526
2627 if (LLVMGetBitcodeModuleInContext2(C, MemBuf, &M))
27 llvm_raise(*caml_named_value("Llvm_bitreader.Error"), "");
28 llvm_raise(*caml_named_value("Llvm_bitreader.Error"), LLVMCreateMessage(""));
2829
2930 return M;
3031 }
3435 LLVMModuleRef M;
3536
3637 if (LLVMParseBitcodeInContext2(C, MemBuf, &M))
37 llvm_raise(*caml_named_value("Llvm_bitreader.Error"), "");
38 llvm_raise(*caml_named_value("Llvm_bitreader.Error"), LLVMCreateMessage(""));
3839
3940 return M;
4041 }
1414 |* *|
1515 \*===----------------------------------------------------------------------===*/
1616
17 #include "llvm-c/Core.h"
1718 #include "llvm-c/Linker.h"
1819 #include "caml/alloc.h"
1920 #include "caml/memory.h"
2526 /* llmodule -> llmodule -> unit */
2627 CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src) {
2728 if (LLVMLinkModules2(Dst, Src))
28 llvm_raise(*caml_named_value("Llvm_linker.Error"), "Linking failed");
29 llvm_raise(*caml_named_value("Llvm_linker.Error"), LLVMCreateMessage("Linking failed"));
2930
3031 return Val_unit;
3132 }
1818 #include
1919 #include
2020 #include "llvm-c/Core.h"
21 #include "llvm-c/Support.h"
2122 #include "caml/alloc.h"
2223 #include "caml/custom.h"
2324 #include "caml/memory.h"