[LLVMbugs] [Bug 21263] New: Add compile-time mangler of C++ types, extern functions

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Oct 13 13:06:03 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21263

            Bug ID: 21263
           Summary: Add compile-time mangler of C++ types, extern
                    functions
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Modules
          Assignee: unassignedclangbugs at nondot.org
          Reporter: s_bugzilla at nedprod.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

It would be really nice if one could inspect a DLL or shared object for things
to load in a type safe way which catches ABI mismatching. To that end, if clang
provided a facility for getting the mangled equivalent of C++ types and extern
function declarations such that one could feed that mangled representation to
dlsym() or GetProcAddress() that would be very useful.

As an example, I'd like this to work:

namespace a { namespace b { extern std::pair<int, double>
hello(boost::variant<int, double>); } }

static const char hello_mangled=__DECORATED__(a::b::hello);

This would also work though:

static const char pair_mangled=__DECORATED__(std::pair<int, double>);
static const char hello_signature_mangled=__DECORATED__(&a::b::hello); //
mangles a std::pair<int, double>(boost::variant<int, double>) callable type

It would also be super nice if __DECORATED__() with no arguments could be used
as a magic macro like __FUNCDNAME__ can on MSVC:

void foo(int)
{
  __DECORATED__() == whatever the current function's mangled symbol is,
equivalent to __FUNCDNAME__ when building against the MSVC ABI
}

Note that one can get most of the way there already using
std::type_info::name() in unholy ways e.g. by instantiating a shim type closely
resembling the extern function, and then running regex transformations on the
mangling to yield what is probably the exported function mangling. One would
rather something less brittle however. As the compiler already knows the
mangling for types and extern things, making this available at compile time
ought to be trivial. And useful.

Niall

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141013/75199474/attachment.html>


More information about the llvm-bugs mailing list