[patches] Alternatives for static functions in extern C contexts

Richard Smith richard at metafoo.co.uk
Wed Feb 20 20:00:43 PST 2013


On Wed, Feb 20, 2013 at 5:22 PM, Richard Smith <richard at metafoo.co.uk>wrote:

> On Wed, Feb 20, 2013 at 3:19 PM, Rafael EspĂ­ndola <
> rafael.espindola at gmail.com> wrote:
>
>> Ping. Any preferences?
>
>
> Both patches seem like an improvement on the status quo to me. I'm waiting
> to hear opinions from CWG.
>

OK, apparently CWG discussed and decided this 12 years ago.

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#4

I wonder how much code is actually broken by mangle_static_extern_c.patch.
LLVM is probably not a representative measure here -- IIRC all the hits in
LLVM code were in the JITs.

 On 15 February 2013 10:08, Rafael EspĂ­ndola <rafael.espindola at gmail.com>
>> wrote:
>> > 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130220/309520d2/attachment.html>


More information about the cfe-commits mailing list