[cfe-commits] r88960 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaCXX/composite-pointer-type.cpp

Douglas Gregor dgregor at apple.com
Mon Nov 16 20:21:01 PST 2009


On Nov 16, 2009, at 1:03 PM, Sebastian Redl wrote:

> Author: cornedbee
> Date: Mon Nov 16 15:03:45 2009
> New Revision: 88960
>
> URL: http://llvm.org/viewvc/llvm-project?rev=88960&view=rev
> Log:
> Repair broken FindCompositePointerType. Correct early termination  
> condition. Get CVR qualifiers from canonical types. Traverse  
> collected qualifiers in reverse order on rebuilding the pointer, so  
> that we don't swap inner and outer qualifiers. That last one fixes  
> PR5509.
>
> Modified:
>    cfe/trunk/lib/Sema/SemaExprCXX.cpp
>    cfe/trunk/test/SemaCXX/composite-pointer-type.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=88960&r1=88959&r2=88960&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Mon Nov 16 15:03:45 2009
> @@ -1884,8 +1884,6 @@
>       !T2->isPointerType() && !T2->isMemberPointerType())
>    return QualType();
>
> -  // FIXME: Do we need to work on the canonical types?
> -
>   // C++0x 5.9p2
>   //   Pointer conversions and qualification conversions are  
> performed on
>   //   pointer operands to bring them to their composite pointer  
> type. If
> @@ -1907,8 +1905,8 @@
>   }
>
>   // Now both have to be pointers or member pointers.
> -  if (!T1->isPointerType() && !T1->isMemberPointerType() &&
> -      !T2->isPointerType() && !T2->isMemberPointerType())
> +  if ((!T1->isPointerType() && !T1->isMemberPointerType()) ||
> +      (!T2->isPointerType() && !T2->isMemberPointerType()))
>     return QualType();
>
>   //   Otherwise, of one of the operands has type "pointer to cv1  
> void," then
> @@ -1922,9 +1920,13 @@
>   // conversions in both directions. If only one works, or if the  
> two composite
>   // types are the same, we have succeeded.
>   // FIXME: extended qualifiers?
> -  llvm::SmallVector<unsigned, 4> QualifierUnion;
> -  llvm::SmallVector<std::pair<const Type *, const Type *>, 4>  
> MemberOfClass;
> -  QualType Composite1 = T1, Composite2 = T2;
> +  typedef llvm::SmallVector<unsigned, 4> QualifierVector;
> +  QualifierVector QualifierUnion;
> +  typedef llvm::SmallVector<std::pair<const Type *, const Type *>, 4>
> +      ContainingClassVector;
> +  ContainingClassVector MemberOfClass;
> +  QualType Composite1 = Context.getCanonicalType(T1),
> +           Composite2 = Context.getCanonicalType(T2);

With r89018, we shouldn't need to get the canonical type here any  
more: desugaring and the "deep" getCVRQualifiers code should do the  
right thing, and we might end up keeping better typedef information if  
we don't go to the canonical type.

It's not a necessary change; just an observation.

	- Doug



More information about the cfe-commits mailing list