[cfe-commits] r92289 - in /cfe/trunk: include/clang/AST/Type.h lib/Sema/SemaTemplateDeduction.cpp test/SemaTemplate/deduction.cpp

Chris Lattner clattner at apple.com
Tue Dec 29 21:58:13 PST 2009

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.


More information about the cfe-commits mailing list