[llvm] r265116 - [OCaml] Use LLVMCreateMessage with constant strings when calling llvm_raise
Jeroen Ketema via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 1 00:56:18 PDT 2016
Author: jketema
Date: Fri Apr 1 02:56:17 2016
New Revision: 265116
URL: http://llvm.org/viewvc/llvm-project?rev=265116&view=rev
Log:
[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
Modified:
llvm/trunk/bindings/ocaml/analysis/analysis_ocaml.c
llvm/trunk/bindings/ocaml/bitreader/bitreader_ocaml.c
llvm/trunk/bindings/ocaml/linker/linker_ocaml.c
llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
Modified: llvm/trunk/bindings/ocaml/analysis/analysis_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/analysis/analysis_ocaml.c?rev=265116&r1=265115&r2=265116&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/analysis/analysis_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/analysis/analysis_ocaml.c Fri Apr 1 02:56:17 2016
@@ -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"
Modified: llvm/trunk/bindings/ocaml/bitreader/bitreader_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/bitreader/bitreader_ocaml.c?rev=265116&r1=265115&r2=265116&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/bitreader/bitreader_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/bitreader/bitreader_ocaml.c Fri Apr 1 02:56:17 2016
@@ -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(L
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_bitcod
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;
}
Modified: llvm/trunk/bindings/ocaml/linker/linker_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/linker/linker_ocaml.c?rev=265116&r1=265115&r2=265116&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/linker/linker_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/linker/linker_ocaml.c Fri Apr 1 02:56:17 2016
@@ -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 *M
/* 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;
}
Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=265116&r1=265115&r2=265116&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Fri Apr 1 02:56:17 2016
@@ -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"
More information about the llvm-commits
mailing list