[PATCH] D69592: [ELF] Suggest the unmangled name as an alternative spelling
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 30 14:12:09 PDT 2019
dblaikie added a comment.
Doing this in both directions (when referencing a C definition with a C++ mangled name, or a C++ definition with an unmangled/C name) seems important/valuable. One comes from using a C header from C++ without wrapping it in "extern "C"" (hopefully inside the header, so it can be used reliably) and the other way happens when you want to write your C API's implementation in C++ (for C interop from a C++ library) but you haven't put "extern"C"" in the declaration of those functions in the header to be used from both C and C++.
But it could be done in two patches rather than trying to cover both cases here, if that's easier.
================
Comment at: lld/ELF/Relocations.cpp:764
+ // suggesting the part before (.
+ std::string demangled = toString(sym);
+ auto paren = demangled.find('(');
----------------
grimar wrote:
> I wonder if we might want to check `if (name.startswith("_Z"))` first. It might save a bit of calculations and isolate the logic a bit.
Rather than demangling and stringifying the whole name, then using a heuristic to find the function name - might it be better to use LLVM's demangling APIs to retrieve the name directly? llvm::itanium_demangle::Node::getBaseName
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69592/new/
https://reviews.llvm.org/D69592
More information about the llvm-commits
mailing list