Hello Clang experts,

Could you help me, please, to understand how does ObjCInterfaceTypeLoc class suppose to work?
ObjCInterfaceTypeLoc is the only one class in TypeLoc hierarchy which inherits twice from ConcreteTypeLoc.
I see in source code and visually at

It is derived from ObjCObjectTypeLoc (which uses ObjCObjectTypeLocInfo),
but has own ObjCInterfaceLocInfo (passed as LocalData).
Does it replace the ObjCObjectTypeLocInfo used by ObjCObjectTypeLoc?
ObjCInterfaceLocInfo is not derived from ObjCObjectTypeLocInfo, so sizeof(ObjCInterfaceLocInfo) < sizeof(ObjCObjectTypeLocInfo)
How methods of ObjCObjectTypeLoc can work for ObjCInterfaceTypeLoc instance?
Shouldn't it be more like:


Hi Vladimir,

It looks to me that this is a bug. However, it currently seems to works because ObjCInterfaceLocInfo is initialized through ObjCObjectTypeLoc so ObjCObjectTypeLocInfo is valid, and after that we initialize ObjCInterfaceTypeLocInfo. I guess that we don’t really see the effect of the bug because we don’t have tests that check for conflict between the name location from ObjCInterfaceTypeLocInfo and left angle/right angle locations from ObjCObjectTypeLoc.
I think that it would make sense for ObjCInterfaceTypeLoc to derive from ObjCObjectTypeLoc directly. I’ll try to clean it up.


Hi Alex,

Are you sure, that this is valid? All *Loc classes memory initialization is done through TypeSourceInfo which prepares memory of corresponding size for TypeLoc data (clang::ASTContext::CreateTypeSourceInfo). So for So may be class ObjCInterfaceTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc, ObjCInterfaceTypeLoc, ObjCInterfaceType, ObjCInterfaceLocInfo> { I thought for inheritance you need same-structured LocInfo and use InheritingConcreteTypeLoc Vladimir.