[cfe-commits] r53823 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/Sema/SemaExpr.cpp
Chris Lattner
sabre at nondot.org
Sun Jul 20 21:36:39 PDT 2008
Author: lattner
Date: Sun Jul 20 23:36:39 2008
New Revision: 53823
URL: http://llvm.org/viewvc/llvm-project?rev=53823&view=rev
Log:
simplify a bunch of code, no functionality change.
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=53823&r1=53822&r2=53823&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sun Jul 20 23:36:39 2008
@@ -383,8 +383,13 @@
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) {
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=53823&r1=53822&r2=53823&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Jul 20 23:36:39 2008
@@ -583,6 +583,8 @@
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();
@@ -591,7 +593,8 @@
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())
@@ -610,26 +613,20 @@
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();
More information about the cfe-commits
mailing list