On Tue, Dec 29, 2009 at 10:22 PM, John McCall <[email protected]> wrote: > On Dec 29, 2009, at 9:58 PM, Chris Lattner wrote: >> On Dec 29, 2009, at 8:53 PM, John McCall wrote: >>> On Dec 29, 2009, at 8:10 PM, Chandler Carruth wrote: >>>> +/// getCVRQualifiersThroughArrayTypes - If there are CVR qualifiers for >>>> this >>>> +/// type, returns them. Otherwise, if this is an array type, recurses >>>> +/// on the element type until some qualifiers have been found or a >>>> non-array >>>> +/// type reached. >>>> +inline unsigned QualType::getCVRQualifiersThroughArrayTypes() const { >>>> + if (unsigned Quals = getCVRQualifiers()) >>>> + return Quals; >>>> + QualType CT = getTypePtr()->getCanonicalTypeInternal(); >>>> + if (const ArrayType *AT = dyn_cast<ArrayType>(CT)) >>>> + return AT->getElementType().getCVRQualifiersThroughArrayTypes(); >>>> + return 0; >>>> +} >>> >>> The CVR qualifiers on an array type are the union of the CVR qualifiers on >>> every level of the type. You can't just stop at the first level that >>> defines CVR qualifiers (well, unless it defines all the qualifiers, but >>> that's not worth checking for). >>> >>> Also I'm suspicious of adding a new accessor for this; I think >>> QualType::getCVRQualifiers(), isConstQualified(), etc. just need to look >>> through array types the same way getAddressSpace() does. If that's >>> prohibitively expensive, we should solve that problem separately, probably >>> by duplicating qualifiers at all levels in the canonical types for arrays. >> >> This should just be looking at the CVR qualifiers of the canonical type for >> the array. If those CVR qualifiers aren't right, that should be fixed. It >> shouldn't be fixed by adding new stuff like this. > > > To clarify, what is the canonical type for T in the following? > typedef const int A[10]; > typedef volatile A T[5]; > (a) 5-array of 10-array of const volatile int (the current) > (b) const volatile 5-array of 10-array of int > (c) const volatile 5-array of const volatile 10-array of const volatile int > > I personally favor (c); I think I've even proposed this before, but I don't > remember why it was counter-indicated. It would certainly make qualifier > queries much easier and faster.
Ahh, this answers my question then. I'll wait to see what folks say, but I'm not opposed to the representation. > > John. > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
