summaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
authorJeroen Ketema <j.ketema@imperial.ac.uk>2016-04-01 07:56:17 +0000
committerJeroen Ketema <j.ketema@imperial.ac.uk>2016-04-01 07:56:17 +0000
commitf4430ca01de933e7608a244915c33c76723474a2 (patch)
tree3f52ca3dbf3704ea34ed0a04a3a3e3a645dcc9a2 /bindings
parent145384cb84d3725f73aa45362c7c97795c0dd6f5 (diff)
[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
Diffstat (limited to 'bindings')
-rw-r--r--bindings/ocaml/analysis/analysis_ocaml.c2
-rw-r--r--bindings/ocaml/bitreader/bitreader_ocaml.c5
-rw-r--r--bindings/ocaml/linker/linker_ocaml.c3
-rw-r--r--bindings/ocaml/llvm/llvm_ocaml.c1
4 files changed, 7 insertions, 4 deletions
diff --git a/bindings/ocaml/analysis/analysis_ocaml.c b/bindings/ocaml/analysis/analysis_ocaml.c
index 9b746d626d5..8b8263d9f33 100644
--- a/bindings/ocaml/analysis/analysis_ocaml.c
+++ b/bindings/ocaml/analysis/analysis_ocaml.c
@@ -15,8 +15,8 @@
|* *|
\*===----------------------------------------------------------------------===*/
-#include "llvm-c/Core.h"
#include "llvm-c/Analysis.h"
+#include "llvm-c/Core.h"
#include "caml/alloc.h"
#include "caml/mlvalues.h"
#include "caml/memory.h"
diff --git a/bindings/ocaml/bitreader/bitreader_ocaml.c b/bindings/ocaml/bitreader/bitreader_ocaml.c
index f91b092d917..6d957760cff 100644
--- a/bindings/ocaml/bitreader/bitreader_ocaml.c
+++ b/bindings/ocaml/bitreader/bitreader_ocaml.c
@@ -13,6 +13,7 @@
\*===----------------------------------------------------------------------===*/
#include "llvm-c/BitReader.h"
+#include "llvm-c/Core.h"
#include "caml/alloc.h"
#include "caml/fail.h"
#include "caml/memory.h"
@@ -25,7 +26,7 @@ CAMLprim LLVMModuleRef llvm_get_module(LLVMContextRef C, LLVMMemoryBufferRef Mem
LLVMModuleRef M;
if (LLVMGetBitcodeModuleInContext2(C, MemBuf, &M))
- llvm_raise(*caml_named_value("Llvm_bitreader.Error"), "");
+ llvm_raise(*caml_named_value("Llvm_bitreader.Error"), LLVMCreateMessage(""));
return M;
}
@@ -35,7 +36,7 @@ CAMLprim LLVMModuleRef llvm_parse_bitcode(LLVMContextRef C, LLVMMemoryBufferRef
LLVMModuleRef M;
if (LLVMParseBitcodeInContext2(C, MemBuf, &M))
- llvm_raise(*caml_named_value("Llvm_bitreader.Error"), "");
+ llvm_raise(*caml_named_value("Llvm_bitreader.Error"), LLVMCreateMessage(""));
return M;
}
diff --git a/bindings/ocaml/linker/linker_ocaml.c b/bindings/ocaml/linker/linker_ocaml.c
index 498a5f0c845..08737bd5843 100644
--- a/bindings/ocaml/linker/linker_ocaml.c
+++ b/bindings/ocaml/linker/linker_ocaml.c
@@ -15,6 +15,7 @@
|* *|
\*===----------------------------------------------------------------------===*/
+#include "llvm-c/Core.h"
#include "llvm-c/Linker.h"
#include "caml/alloc.h"
#include "caml/memory.h"
@@ -26,7 +27,7 @@ void llvm_raise(value Prototype, char *Message);
/* llmodule -> llmodule -> unit */
CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src) {
if (LLVMLinkModules2(Dst, Src))
- llvm_raise(*caml_named_value("Llvm_linker.Error"), "Linking failed");
+ llvm_raise(*caml_named_value("Llvm_linker.Error"), LLVMCreateMessage("Linking failed"));
return Val_unit;
}
diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c
index b4c47e7475e..925f3bdb600 100644
--- a/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/bindings/ocaml/llvm/llvm_ocaml.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include "llvm-c/Core.h"
+#include "llvm-c/Support.h"
#include "caml/alloc.h"
#include "caml/custom.h"
#include "caml/memory.h"