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.

John.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to