[patches] Alternatives for static functions in extern C contexts

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Feb 15 07:08:05 PST 2013


I have changed llvm so that it doesn't depend on the mangling of
static functions in extern C contexts. Now we should decide what to do
in clang.

I have attached two options on how to handle

extern "C" {
  static void foo();
}

The assign_c_language_linkage patch assigns C language linkage to any
function or variable with linkage, instead of just the ones with
external linkage. It looks like this is what gcc does.

The mangle_static_extern_c implements the current letter of the
standard, which requires some mangling of static functions. We can try
to improve it so that given

extern "C" {
  static void foo() {
  }
  static void bar() {
  }
  static void bar(int x) {
  }
}

it produces the symbols foo, _Z3barv and _Z3bari, but it doesn't look
trivial to find out in shouldMangleDeclName if a function is
overloaded or not.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: assign_c_language_linkage.patch
Type: application/octet-stream
Size: 6206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130215/5eb65f51/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mangle_static_extern_c.patch
Type: application/octet-stream
Size: 2779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130215/5eb65f51/attachment-0001.obj>


More information about the cfe-commits mailing list