This is an archive of the discontinued LLVM Phabricator instance.

[OCaml] Use LLVMCreateMessage with constant strings when calling llvm_raise
ClosedPublic

Authored by jketema on Mar 31 2016, 1:54 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

jketema updated this revision to Diff 52281.Mar 31 2016, 1:54 PM
jketema retitled this revision from to [OCaml] Use LLVMCreateMessage with constant strings when calling llvm_raise.
jketema updated this object.
jketema added a reviewer: whitequark.
jketema added a subscriber: llvm-commits.
whitequark accepted this revision.Mar 31 2016, 11:09 PM
whitequark edited edge metadata.

LGTM

This revision is now accepted and ready to land.Mar 31 2016, 11:09 PM
This revision was automatically updated to reflect the committed changes.

By the way, it would be wonderful if you found a moment to add support for LLVMContextSetDiagnosticHandler—it's in my backlog for a while, but I'm unlikely to get to it soon... right now the error messages from the OCaml bindings are quite useless.

Yeah something needs to be done with LLVMContextSetDiagnosticHandler anyway, as two regression tests currently fail because no handler is installed. I might do an easy fix for that first (just to get the tests back in working order) and then revisit how to properly expose the handlers.