[PATCH] D53841: [OCaml] Fix incorrect use of CAMLlocal in nested blocks

whitequark via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 7 20:04:24 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL346387: [OCaml] Fix incorrect use of CAMLlocal in nested blocks (authored by whitequark, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D53841

Files:
  llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c


Index: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
===================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
+++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
@@ -483,9 +483,9 @@
 CAMLprim value llvm_struct_name(LLVMTypeRef Ty)
 {
   CAMLparam0();
+  CAMLlocal1(result);
   const char *C = LLVMGetStructName(Ty);
   if (C) {
-    CAMLlocal1(result);
     result = caml_alloc_small(1, 0);
     Store_field(result, 0, caml_copy_string(C));
     CAMLreturn(result);
@@ -636,6 +636,7 @@
 
 CAMLprim value llvm_classify_value(LLVMValueRef Val) {
   CAMLparam0();
+  CAMLlocal1(result);
   if (!Val)
     CAMLreturn(Val_int(NullValue));
   if (LLVMIsAConstant(Val)) {
@@ -652,7 +653,6 @@
     DEFINE_CASE(Val, ConstantVector);
   }
   if (LLVMIsAInstruction(Val)) {
-    CAMLlocal1(result);
     result = caml_alloc_small(1, 0);
     Store_field(result, 0, Val_int(LLVMGetInstructionOpcode(Val)));
     CAMLreturn(result);
@@ -822,12 +822,11 @@
 /* llvalue -> string option */
 CAMLprim value llvm_get_mdstring(LLVMValueRef V) {
   CAMLparam0();
+  CAMLlocal2(Option, Str);
   const char *S;
   unsigned Len;
 
   if ((S = LLVMGetMDString(V, &Len))) {
-    CAMLlocal2(Option, Str);
-
     Str = caml_alloc_string(Len);
     memcpy(String_val(Str), S, Len);
     Option = alloc(1,0);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53841.173115.patch
Type: text/x-patch
Size: 1333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181108/4cf28b21/attachment.bin>


More information about the llvm-commits mailing list