On Sat, Aug 25, 2012 at 5:16 AM, John McCall <[email protected]> wrote:
> On Jul 31, 2012, at 4:32 AM, Timur Iskhodzhanov wrote:
>> On Tue, Jul 31, 2012 at 4:56 AM, John McCall <[email protected]> wrote:
>>> On Jul 27, 2012, at 7:30 AM, Timur Iskhodzhanov wrote:
>>>> Attached is an updated patch which has slightly uglier code (due to
>>>> code duplication) but better mangling.
>>>> The "eta" mangling remains the same, "_E$$A6" has been replaced with
>>>> "_E" everywhere.
>>>
>>> +  QualType pointee = T->getPointeeType();
>>> +  assert(isa<FunctionProtoType>(pointee));
>>> +  mangleType(static_cast<const FunctionProtoType*>(pointee.getTypePtr()), 
>>> NULL, false, false);
>>>
>>> The easier way to do an assert-and-cast is like this:
>>>  cast<FunctionProtoType>(pointee)
>>>
>>> However, you can't actually do a cast here, because there could be a 
>>> typedef in the way.  Test case:
>>>  typedef void fn();
>>>  void foo(fn^ block) { block(); }
>>>
>>> So instead you need to do this:
>>>  pointee->castAs<FunctionProtoType>()
>>> This is like getAs<>, but asserting.
>> Thanks for the tip!
>> See the updated patch.
>
> I turned a few extra getAs<> calls into castAs<>
oops I've forgotten to do that, sorry!

> and committed as r162638.
Thanks a lot!

>> FTR, the idea of using static_cast came to me after looking at
>> MicrosoftMangle:972.
>> Probably, static_cast should be replaced with getAs/castAs there too ?
>
> If it's working on a canonical type, static_cast is fine, although we 
> generally
> prefer cast<> in such cases.  If it's not a canonical type, it should be 
> castAs.
Not sure here
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to