[cfe-commits] r107264 - in /cfe/trunk: lib/CodeGen/MicrosoftCXXABI.cpp test/CodeGenCXX/mangle-ms.cpp

Douglas Gregor dgregor at apple.com
Wed Jun 30 16:42:42 PDT 2010

On Jun 30, 2010, at 4:37 PM, Charles Davis wrote:

> On 6/30/10 4:32 PM, Douglas Gregor wrote:
>> On Jun 30, 2010, at 3:30 PM, Charles Davis wrote:
>>> On 6/30/10 2:58 PM, John McCall wrote:
>>>> On Jun 30, 2010, at 1:44 PM, Charles Davis wrote:
>>>>> On 6/30/10 2:10 PM, John McCall wrote:
>>>>>> On Jun 30, 2010, at 1:05 PM, Charles Davis wrote:
>>>>>>> The "proper" way IMO is to store it in the FunctionType's argument list as an IncompleteArrayType and have canonicalization of the function type decay it to a pointer. Then the mangler will detect that it's mangling a parameter array and mangle it as a const pointer. At least, there really should be some way of detecting that a parameter was declared as an array instead of a pointer.
>>>>>> The type-as-written for the parameter declaration remembers this.
>>>>> How do you get that from a FunctionType? As far as I know, you need a
>>>>> FunctionDecl to get the ParmVarDecls. We don't always have
>>>>> one--particularly when we're mangling pointers to functions (which I
>>>>> haven't really looked at yet).
>>>> Right, which was why I asked about it.
>>>> Does MSVC mangle any other kind of "sugar" differently?  Do all the following
>>>> have the same mangling?
>>>> typedef int Int;
>>>> typedef int IntArray[10];
>>>> void foo(int x[10]);
>>>> void foo(Int x[10]);
>>>> void foo(IntArray x);
>>> They are all mangled the same (?foo@@YAXQAH at Z). I'm pretty sure that
>>> typedefs are canonicalized away (except in the case of anonymous tag types).
>> Here's a question: if you take the address of "foo", what type do you get? is the "const" in the resulting type?
> Hard to tell; apparently, MSVC allows both of these:
> void (*pfoo)(int * const) = &foo;
> void (*pfoo2)(int *) = &foo;
> These work too:
> void bar(int);
> void (*pbar)(int) = &bar;
> void (*pbar2)(const int) = &bar;
> My guess is that MSVC's semantic analyzer doesn't consider qualifiers on
> types in parameters, but it preserves this information for the name mangler.

Ah, that's correct behavior: cv-qualifiers on parameters are deleted. It really feels like you'll be stuck looking at the TypeSourceInfo for a function type to determine whether it was originally declared as an array :(

	- Doug

More information about the cfe-commits mailing list