[cfe-commits] r45269 - in /cfe/trunk: AST/ASTContext.cpp test/Sema/objc-comptypes-1.m test/Sema/objc-string.m

Chris Lattner clattner at apple.com
Fri Jan 4 15:40:56 PST 2008


On Dec 20, 2007, at 2:37 PM, Fariborz Jahanian wrote:
> Author: fjahanian
> Date: Thu Dec 20 16:37:58 2007
> New Revision: 45269
>
> URL: http://llvm.org/viewvc/llvm-project?rev=45269&view=rev
> Log:
> More objective-c type checking. This time comparing objective-c  
> known objects.

Hi Fariborz,

> bool ASTContext::interfaceTypesAreCompatible(QualType lhs, QualType  
> rhs) {
> +  if (lhs == rhs)
> +    return true;
> +  ObjcInterfaceType *lhsIT =  
> cast<ObjcInterfaceType>(lhs.getTypePtr());
> +  ObjcInterfaceType *rhsIT =  
> cast<ObjcInterfaceType>(rhs.getTypePtr());

This doesn't work with typedefs of interfaces because it isn't looking  
through them.  Please use lhs->getAsObjCInterfaceType() (implementing  
it if needed) or add an assertion that the types coming in are  
canonical, document this in the interface, and verify that this is  
true in the callers.

As a bigger more general question, we have type compatibility stuff  
split between Sema and ASTContext.  Is this what we really want?   
Should it all go in ASTContext or all in Sema?  Methods like  
'interfaceTypesAreCompatible' are really just helper functions in the  
implementation of "are types compatible", they shouldn't be a public  
ASTContext interface IMO.  What do you think?

-Chris



More information about the cfe-commits mailing list