[cfe-dev] Fixing MemberPointerTypeLoc.

Abramo Bagnara abramo.bagnara at gmail.com
Fri Mar 4 10:23:59 PST 2011


Il 04/03/2011 16:20, Douglas Gregor ha scritto:
> 
> On Mar 4, 2011, at 2:24 AM, Enea Zaffanella wrote:
> 
>> Hello.
>>
>> We would like to get rid of the FIXME in MemberPointerTypeLoc so as to
>> provide appropriate NNSLoc info. As an example of the current problem,
>> code such as the following:
>>
>> int S<int[2+3]>::* ptr = 0;
>>
>> gets printed as follows (note that the array size is computed):
>>
>> int S<int [5]>::*ptr = 0;
>>
>> The situation seems to be much like that of ElaboratedTypeLoc, except
>> for the fact that in ElaboratedType we do have an NestedNameSpecifier,
>> while in MemberPointerType we have instead
>>
>>  /// The class of which the pointee is a member. Must ultimately be a
>>  /// RecordType, but could be a typedef or a template parameter too.
>>  const Type *Class;
>>
>>
>> So, what would be the best way to proceed?
>>
>> Can we _add_ a NNS* to MemberPointerType?
>>
>> Should we _replace_ the Type* with the NNS* and have the method
>> getClass() recompute the class type on the fly?
> 
> I think this is the best option, since it allows us to represent the source accurately without making MemberPointerType larger. Thanks for working on this!

In theory it was the best options, but to recompute the class type
inside getClass() we definitely need to have the ASTContext, right?

There are 48 callers of getClass() and some call it from contexts where
ASTContext is unreachable.

I'd suggest to choose another solution among:

1) add a NNS* to MemberPointerType
2) add a TypeSourceInfo* for the class type to the MemberPointerTypeLoc
3) other ideas?



More information about the cfe-dev mailing list