This is an archive of the discontinued LLVM Phabricator instance.

[OCaml] Add OCaml API for __cxa_demangle
AbandonedPublic

Authored by jberdine on Sep 17 2018, 6:25 PM.

Details

Reviewers
whitequark
Summary

Adds a demangle function to the OCaml API to expose the internal
implementation of __cxa_demangle. This is useful for OCaml clients
which would not otherwise link to libstdc++.

Diff Detail

Event Timeline

jberdine created this revision.Sep 17 2018, 6:25 PM
whitequark requested changes to this revision.Sep 17 2018, 6:46 PM

I'm not sure if this function has a place here. It's not a function provided by the LLVM API, and it's platform-specific. I think with this change it would not be possible to build the OCaml bindings under MSVC, for example.

This revision now requires changes to proceed.Sep 17 2018, 6:46 PM

Using the copy of the demangler in LLVMDemangle would solve the issues @whitequark brought up, FWIW.

Thanks for the suggestion @erik.pilkington. I assume you mean to call the itaniumDemangle function declared in include/llvm/Demangle/Demanagle.h. Since that is in the llvm namespace, it would need a shim extern C function in C++ to call from the OCaml bindings. It's not clear to me that such a function would be welcome in e.g. lib/IR/Core.cpp. There could be other options I'm overlooking. My brief experiments adding some C++ code under bindings/ocaml all failed to compile, but maybe there is some build system magic that would make that work. But since it is possible for clients of the OCaml API to call __cxa_demangle without exposing it here, maybe @whitequark is right that it doesn't fit.

jberdine abandoned this revision.Oct 8 2018, 3:53 PM