[PATCH] D52239: [OCaml] Add OCaml APIs to access DebugLoc info

Josh Berdine via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 16 13:56:16 PDT 2019


jberdine marked 3 inline comments as done.
jberdine added inline comments.


================
Comment at: bindings/ocaml/llvm/llvm_ocaml.c:887
+  unsigned dbg = LLVMGetMDKindID("dbg", 3);
+  for (int i = 0; i < NumEntries; i++) {
+    if (LLVMValueMetadataEntriesGetKind(Entries, i) == dbg) {
----------------
@codafi, is this the filter to find the debug info for a global variable you had in mind?


================
Comment at: bindings/ocaml/llvm/llvm_ocaml.c:890
+      LLVMMetadataRef GVE = LLVMValueMetadataEntriesGetMetadata(Entries, i);
+      if (GVE) {
+        Var = LLVMDIGlobalVariableExpressionGetVariable(GVE);
----------------
This is the only null check I have not seen fail in practice. It's not a big deal, but I wonder if I am overlooking some reason that guarantees that it is always valid.


================
Comment at: bindings/ocaml/llvm/llvm_ocaml.c:896
+  }
+  LLVMDisposeValueMetadataEntries(Entries);
+  return Var;
----------------
My understanding is that this deallocation is safe since the returned var already existed in the context, rather than being copied by LLVMGlobalCopyAllMetadata, but a sanity check would be welcome.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52239/new/

https://reviews.llvm.org/D52239





More information about the llvm-commits mailing list