[cfe-commits] [PATCH] Encoding calling conventions in FunctionTypes

Douglas Gregor dgregor at apple.com
Mon Jan 18 09:15:53 PST 2010


On Jan 13, 2010, at 2:50 PM, Charles Davis wrote:

> Douglas Gregor wrote:
>> Hi Chip,
>>
>> On Jan 4, 2010, at 3:13 PM, Charles Davis wrote:
>>
>>> Ping...
>>>
>>> Patch is reattached, rebased against current TOT.
>>
>> Thanks for your patience; comments below.
> Sorry it took so long. Actually, the reason it took so long is that I
> was on vacation :).
>
> Anyway, latest patch reattached.

Thanks!

>>> +static bool isCompatibleCallingConvention(CallingConv lcc,
>>> CallingConv rcc) {
>>> +  // Here are the rules (as I see them) for compatibility of  
>>> calling
>>> +  // conventions:
>>> +  // - If they're the same, they're compatible.
>>> +  // - If the first one is not the default and the second one is,  
>>> then
>>> +  //   they're compatible (and the second declaration assumes the
>>> calling
>>> +  //   convention of the first).
>>> +  // - Otherwise, they're not compatible.
>>> +  return (lcc == rcc || (lcc != CC_Default && rcc == CC_Default));
>>> +}
>>
>> The order dependency on lcc/rcc doesn't make sense to me, since the
>> definition of compatibility for types is commutative. I think the  
>> right
>> implementation for this function is to compare the canonical calling
>> conventions.
> As I said the case I had in mind is this one:
>
> void __attribute__((stdcall)) f(void);
> void f(void) {}
>
> or the equivalent MSVC:
>
> void __stdcall f(void);
> void f(void) {}
>
> MSVC lets you do that. Oddly enough, I found that GCC doesn't let  
> you do
> that. Apparently, clang already handles that, so my concern was
> unfounded. (Is it?) So, I changed it to just directly compare the
> calling conventions, like you said it should.

I'd expect that the attribute is merged from the first declaration  
down to the second declaration, so this should work.

>>
>> Aside from the canonical-types issue, I think this patch is ready  
>> to go
>> in. Do you have commit access?
> All right! ...But I don't have commit access yet. How do I get it?  
> Or do
> you intend to commit this yourself?


I'll handle the first couple of commits, then we'll look into getting  
you direct commit access. I've committed this patch here:

	http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20100118/026432.html

With one change, because here we should be (and are now) comparing the  
canonical calling conventions:

+static bool isSameCallingConvention(CallingConv lcc, CallingConv rcc) {
+  return (lcc == rcc);
+}

Thanks!

	- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100118/eb26e312/attachment.html>


More information about the cfe-commits mailing list