[cfe-dev] For Review: C++ Casting Patch

Bill Wendling isanbard at gmail.com
Sun Jun 1 18:19:07 PDT 2008

On Apr 16, 2008, at 10:11 PM, Chris Lattner wrote:

> On Apr 16, 2008, at 10:08 PM, Bill Wendling wrote:
>>> +  if (CastTyBase.getTypePtr() == ExprTyBase.getTypePtr())
>>> +    return true;
>>> This isn't safe, one might be a typedef for the other.  Also, you  
>>> should have comments in your methods explaining why you are doing  
>>> what you are doing.
>> At this point, one of them won't be a pointer type. Essentially,  
>> what I want this method to do is go through all of the layers of  
>> both pointer types until it gets to the base type. It then checks  
>> to see if the base types are equal (the code you quoted above). I  
>> take it from your comment that this isn't sufficient to do that.  
>> How do I check past the typedefs when the types may not be pointers  
>> at all? Should I use "getDesugaredType()"?
> For exact equality (including CV qualifiers etc), something like  
> this should work:
> if (SourceMgr.getCanoncicalType(CastTyBase.getTypePtr()) ==  
> SourceMgr.getCanonicalType(ExprTyBase.getTypePtr()))
Here's an updated patch for C++ casting checking.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: c++.patch
Type: application/octet-stream
Size: 19344 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080601/0ef88809/attachment.obj>
-------------- next part --------------

More information about the cfe-dev mailing list