r175132 - Partially revert r175117 so that we don't break assumptions about how

John McCall rjmccall at apple.com
Thu Feb 14 11:03:17 PST 2013


On Feb 13, 2013, at 7:48 PM, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
> On 13 February 2013 22:31, Rafael Espindola <rafael.espindola at gmail.com> wrote:
>> Author: rafael
>> Date: Wed Feb 13 21:31:26 2013
>> New Revision: 175132
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=175132&view=rev
>> Log:
>> Partially revert r175117 so that we don't break assumptions about how
>> static functions in extern "C" contexts are mangled. Should fix the
>> bootstrap.
> 
> This is really ugly, but seems to be a common assumption, so I don't
> think we can1t break it. I considered 3 options
> 
> * Giving C language linkage to static functions in extern C contexts.
> I decided not to do this since it would then require more special
> cases in the callers. For example, without extra care we would go back
> to warning on a static returning non-POD if it defined in an extern C
> context.
> * Adding the restriction just to overloading (this patch).
> * Changing the mangling only when the function is actually overloaded.
> For example, in
> 
> extern "C" {
>  static void foo() {
>  }
>  static void bar() {
>  }
>  static void bar(int x) {
>  }
> }
> 
> we would produce the symbols foo, _Z3barv and _Z3bari. I still like
> the idea, but I could not find an easy way to detect in
> shouldMangleDeclName if the function was overloaded or not.

I understand what you're trying to do here, because indeed the standard
says that language linkage only applies to functions and variables with
external linkage, but I think the right thing to do is to just acknowledge
that we (AFAIK, like gcc) just give C language linkage to everything
declared in extern "C" and be done with it.  There are much more
significant ways in which we deviate from the standard's definition of
language linkage.

John.



More information about the cfe-commits mailing list