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

schaub-johannes at web.de schaub-johannes at web.de
Wed Dec 30 03:49:48 PST 2009


On Wednesday 30 December 2009 07:22:23 John McCall 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.
> 

I want to draw your attention to http://llvm.org/bugs/show_bug.cgi?id=5290 . 
Does (c) mean we should drop qualifiers from array rvalues? 



More information about the cfe-commits mailing list