return false;
}
- ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *ivarName,
- ObjCInterfaceDecl *&clsDeclared);
+ ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName,
+ ObjCInterfaceDecl *&ClassDeclared);
+ ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) {
+ ObjCInterfaceDecl *ClassDeclared;
+ return lookupInstanceVariable(IVarName, ClassDeclared);
+ }
+
// Get the local instance method declared in this interface.
ObjCMethodDecl *getInstanceMethod(Selector Sel) {
QualType BaseType = BaseExpr->getType();
assert(!BaseType.isNull() && "no type for member expression");
+ // Get the type being accessed in BaseType. If this is an arrow, the BaseExpr
+ // must have pointer type, and the accessed type is the pointee.
if (OpKind == tok::arrow) {
if (const PointerType *PT = BaseType->getAsPointerType())
BaseType = PT->getPointeeType();
SourceRange(MemberLoc));
}
- // Handle field access to simple records.
+ // Handle field access to simple records. This also handles access to fields
+ // of the ObjC 'id' struct.
if (const RecordType *RTy = BaseType->getAsRecordType()) {
RecordDecl *RDecl = RTy->getDecl();
if (RTy->isIncompleteType())
MemberType.getCVRQualifiers() | BaseType.getCVRQualifiers();
MemberType = MemberType.getQualifiedType(combinedQualifiers);
- return new MemberExpr(BaseExpr, OpKind==tok::arrow, MemberDecl,
+ return new MemberExpr(BaseExpr, OpKind == tok::arrow, MemberDecl,
MemberLoc, MemberType);
}
// Handle access to Objective C instance variables, such as "Obj->ivar".
- if (BaseType->isObjCInterfaceType()) {
- ObjCInterfaceDecl *IFace;
- QualType CanonType = BaseType.getCanonicalType();
- if (isa<ObjCInterfaceType>(CanonType))
- IFace = dyn_cast<ObjCInterfaceType>(CanonType)->getDecl();
- else
- IFace = dyn_cast<ObjCQualifiedInterfaceType>(CanonType)->getDecl();
- ObjCInterfaceDecl *clsDeclared;
- if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(&Member, clsDeclared))
+ if (const ObjCInterfaceType *IFTy = BaseType->getAsObjCInterfaceType()) {
+ if (ObjCIvarDecl *IV = IFTy->getDecl()->lookupInstanceVariable(&Member))
return new ObjCIvarRefExpr(IV, IV->getType(), MemberLoc, BaseExpr,
OpKind == tok::arrow);
return Diag(OpLoc, diag::err_typecheck_member_reference_structUnion,
SourceRange(MemberLoc));
}
+ // Handle property access.
if (isObjCObjectPointerType(BaseType)) {
const PointerType *pointerType = BaseType->getAsPointerType();
BaseType = pointerType->getPointeeType();