llvm.org GIT mirror llvm / 9ac4c44
[OCaml] Fix incorrect use of CAMLlocal in nested blocks Summary: The OCaml manual states: > Local variables of type value must be declared with one of the > CAMLlocal macros. [...] These macros must be used at the beginning > of the function, not in a nested block. This patch moves several instances of CAMLlocal macros from nested blocks to the function beginning. Reviewers: whitequark Reviewed By: whitequark Subscribers: CodaFi, llvm-commits Differential Revision: https://reviews.llvm.org/D53841 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346387 91177308-0d34-0410-b5e6-96231b3b80d8 whitequark 10 months ago
1 changed file(s) with 3 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
482482 CAMLprim value llvm_struct_name(LLVMTypeRef Ty)
483483 {
484484 CAMLparam0();
485 CAMLlocal1(result);
485486 const char *C = LLVMGetStructName(Ty);
486487 if (C) {
487 CAMLlocal1(result);
488488 result = caml_alloc_small(1, 0);
489489 Store_field(result, 0, caml_copy_string(C));
490490 CAMLreturn(result);
635635
636636 CAMLprim value llvm_classify_value(LLVMValueRef Val) {
637637 CAMLparam0();
638 CAMLlocal1(result);
638639 if (!Val)
639640 CAMLreturn(Val_int(NullValue));
640641 if (LLVMIsAConstant(Val)) {
651652 DEFINE_CASE(Val, ConstantVector);
652653 }
653654 if (LLVMIsAInstruction(Val)) {
654 CAMLlocal1(result);
655655 result = caml_alloc_small(1, 0);
656656 Store_field(result, 0, Val_int(LLVMGetInstructionOpcode(Val)));
657657 CAMLreturn(result);
821821 /* llvalue -> string option */
822822 CAMLprim value llvm_get_mdstring(LLVMValueRef V) {
823823 CAMLparam0();
824 CAMLlocal2(Option, Str);
824825 const char *S;
825826 unsigned Len;
826827
827828 if ((S = LLVMGetMDString(V, &Len))) {
828 CAMLlocal2(Option, Str);
829
830829 Str = caml_alloc_string(Len);
831830 memcpy(String_val(Str), S, Len);
832831 Option = alloc(1,0);