[cfe-commits] [patch] __has_trivial_* type traits

John McCall rjmccall at apple.com
Thu Jul 23 12:57:29 PDT 2009


Douglas Gregor wrote:
> On Jul 23, 2009, at 1:03 AM, John McCall wrote:
>> Index: include/clang/AST/Type.h
>> ===================================================================
>> --- include/clang/AST/Type.h    (revision 76866)
>> +++ include/clang/AST/Type.h    (working copy)
>> @@ -473,6 +473,11 @@ public:
>>   /// element type of the array, potentially with type qualifiers 
>> missing.
>>   /// This method should never be used when type qualifiers are 
>> meaningful.
>>   const Type *getArrayElementTypeNoTypeQual() const;
>> +
>> +  /// getBaseElementTypeNoTypeQual - Recursively strip qualifiers and
>> +  /// array types off this type.  This method should never be used when
>> +  /// type qualifiers are meaningful.
>> +  const Type *getBaseElementTypeNoTypeQual() const;
>
> Why does this operation strip off the qualifiers? Most of the callers 
> of this routine don't mind if the result type is qualified, and the 
> UTT_HasTrivialAssign computation would be far easier if this routine 
> maintained the qualifiers.

Well, there are qualifiers and then there are qualifiers.  I did 
initially have an implementation which just collected the CVR qualifiers 
as it tore down, but it wasn't able to handle the extended qualifiers, 
and I didn't have an ASTContext to work with.  Of course, I should have 
just found a way to get a context;  I'll do that and resubmit.

> This is definitely more complicated than it needs to be.

Yep.

> The logic here looks file. It seems to me like it would be relatively 
> easy to drill down to the base element type, keeping around the union 
> of the qualifiers that have been added at each stage. Then, return a 
> QualType with the base element type and those accumulated qualifiers. 
> Clients that want the unqualified version can just use 
> .getUnqualifiedType() on the result.

In theory there's a performance difference, but I agree it's not worth 
worrying about.

I'll introduce a class to collect qualifiers;  that should make it 
easier if we ever tear ExtQualType out of the hierarchy.

John.



More information about the cfe-commits mailing list