This might need some iteration and more than the accidental test cases it has now, but I'd like to know if I'm on the right path.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
bindings/ocaml/llvm/llvm.ml | ||
---|---|---|
324 ↗ | (On Diff #53004) | Just description and severity. |
bindings/ocaml/llvm/llvm.mli | ||
428 ↗ | (On Diff #53004) | There is no need to have an 'a here since OCaml already has closures; the context argument in C is closure emulation in essence. |
431 ↗ | (On Diff #53004) | Accept an option in set_diagnostic_handler instead of using two functions. |
bindings/ocaml/llvm/llvm_ocaml.c | ||
187 ↗ | (On Diff #53004) | There is caml_raise_out_of_memory and I think we should use it. |
test/Bindings/OCaml/linker.ml | ||
21 ↗ | (On Diff #53004) | Is this (and elsewhere in test/) actually used in tests? |
Thanks for the feedback so far!
bindings/ocaml/llvm/llvm.mli | ||
---|---|---|
428 ↗ | (On Diff #53004) | I had that originally, just wasn't quite sure whether that was desired in this case. I'll remove the 'a |
bindings/ocaml/llvm/llvm_ocaml.c | ||
187 ↗ | (On Diff #53004) | I looked for something like that but couldn't find it. Thanks for the pointer. |
test/Bindings/OCaml/linker.ml | ||
21 ↗ | (On Diff #53004) | It's used in the sense that currently the test crashes, because it tries to read invalid bitcode but no handler is installed. Having diagnostic handlers actually fixes the tests updated in this patch. It's not used in the sense that there's no FileCheck for the printed text. I could make the handler just be empty instead? |
test/Bindings/OCaml/linker.ml | ||
---|---|---|
21 ↗ | (On Diff #53004) | Why not add the check? |
Updated patch based on @whitequark 's feedback. I've also added a separate test to test the diagnostic handler functionality.
bindings/ocaml/llvm/llvm.ml | ||
---|---|---|
317 ↗ | (On Diff #53171) | Just module Diagnostic, I think. |
bindings/ocaml/llvm/llvm_ocaml.c | ||
135 ↗ | (On Diff #53171) | You don't need all this ceremony. LLVMDiagnosticInfoRef is a void* and so is a value and OCaml's runtime is defined to not do anything special with pointers that it doesn't control. So just cast LLVMDiagnosticInfoRef to value. |
178 ↗ | (On Diff #53171) | I would merge these two functions into just llvm_set_diagnostic_handler; there are a few examples of how to handle incoming option values in this codebase. |
test/Bindings/OCaml/diagnostic_handler.ml | ||
31 ↗ | (On Diff #53171) | No check for the proper message and severity? This can hide a bug where the severity or message are mishandled. |
Thanks for reviewing. Note that this doesn't re-enable the binding tests, as one test is still broken after these fixes: the core.ml test tries to build old-style debug information, and the new style is not even exposed in llvm-c. Maybe that part of core.ml should be disabled (or even removed?).