cppast icon indicating copy to clipboard operation
cppast copied to clipboard

Mangled names

Open rokups opened this issue 7 years ago • 7 comments

Would it be possible to expose mangled names? It could be very helpful when generating API wrappers for foreign languages.

rokups avatar Feb 03 '18 14:02 rokups

I see what I can do about it.

foonathan avatar Feb 13 '18 18:02 foonathan

I would be very careful with this. While libclang exposes mangled entity names, these names are specific to the clang compiler (Actually, clang on linux implements itanium iirc). Also nothing prevents LLVM to change the symbol mangling scheme between versions, so you're not guaranteed that your cppast running say libclang 3.8 would work with your lib compiled with 4.0 for example.

Manu343726 avatar Mar 04 '18 10:03 Manu343726

CppSharp project successfully uses mangled names from llvm/clang though.

rokups avatar Mar 04 '18 10:03 rokups

Oh, I see they explicitly support Itanium and MS ABIs, interesting. Thanks for pointing out, I'm curious how they're handling the MSVC case.

Manu343726 avatar Mar 04 '18 11:03 Manu343726

Clang does support msvc ABI. https://clang.llvm.org/docs/MSVCCompatibility.html

rokups avatar Mar 04 '18 12:03 rokups

I am also highly interested in mangled names. Libclang directly supports it https://clang.llvm.org/doxygen/group__CINDEX__MANGLE.html and selects the right mangling depending on the platform.

KevinW1998 avatar Mar 11 '18 13:03 KevinW1998

Okay, I'll add it.

Because I don't have access to the CXCursor (and can't, by design), I'd probably have to add a std::string to cpp_entity, bloating everything again.

I could also store it in the cpp_entity_index but then there's some runtime overhead on access.

foonathan avatar Mar 11 '18 14:03 foonathan