Removed a slot in ObjCMemRegExpr used in

code gen which did not belong there.

llvm-svn: 61203
This commit is contained in:
Fariborz Jahanian 2008-12-18 17:29:46 +00:00
parent d96f7cca5f
commit f8f0c6b1bc
7 changed files with 40 additions and 17 deletions

View File

@ -47,7 +47,10 @@ namespace clang {
class TypeDecl;
class TypedefDecl;
class TemplateTypeParmDecl;
class FieldDecl;
class ObjCIvarRefExpr;
class ObjCIvarDecl;
/// ASTContext - This class holds long-lived AST nodes (such as types and
/// decls) that can be referred to throughout the semantic analysis of a file.
class ASTContext {
@ -74,6 +77,7 @@ class ASTContext {
llvm::DenseMap<const ObjCInterfaceDecl*,
const RecordDecl*> ASTRecordForInterface;
llvm::DenseMap<const ObjCIvarRefExpr*, const FieldDecl*> ASTFieldForIvarRef;
/// BuiltinVaListType - built-in va list type.
/// This is initially null and set by Sema::LazilyCreateBuiltin when
@ -391,6 +395,15 @@ public:
const ASTRecordLayout &getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D);
const RecordDecl *addRecordToClass(const ObjCInterfaceDecl *D);
const FieldDecl *getFieldDecl(const ObjCIvarRefExpr *MRef) {
llvm::DenseMap<const ObjCIvarRefExpr *, const FieldDecl*>::iterator I
= ASTFieldForIvarRef.find(MRef);
assert (I != ASTFieldForIvarRef.end() && "Unable to find field_decl");
return I->second;
}
void setFieldDecl(const ObjCInterfaceDecl *OI,
const ObjCIvarDecl *Ivar,
const ObjCIvarRefExpr *MRef);
//===--------------------------------------------------------------------===//
// Type Operators
//===--------------------------------------------------------------------===//

View File

@ -156,23 +156,20 @@ public:
/// ObjCIvarRefExpr - A reference to an ObjC instance variable.
class ObjCIvarRefExpr : public Expr {
class ObjCIvarDecl *D;
FieldDecl *FD;
SourceLocation Loc;
Stmt *Base;
bool IsArrow:1; // True if this is "X->F", false if this is "X.F".
bool IsFreeIvar:1; // True if ivar reference has no base (self assumed).
public:
ObjCIvarRefExpr(ObjCIvarDecl *d, FieldDecl *fd,
ObjCIvarRefExpr(ObjCIvarDecl *d,
QualType t, SourceLocation l, Expr *base=0,
bool arrow = false, bool freeIvar = false) :
Expr(ObjCIvarRefExprClass, t), D(d), FD(fd),
Expr(ObjCIvarRefExprClass, t), D(d),
Loc(l), Base(base), IsArrow(arrow),
IsFreeIvar(freeIvar) {}
ObjCIvarDecl *getDecl() { return D; }
FieldDecl *getFieldDecl() { return FD; }
const FieldDecl *getFieldDecl() const { return FD; }
const ObjCIvarDecl *getDecl() const { return D; }
virtual SourceRange getSourceRange() const {
return isFreeIvar() ? SourceRange(Loc)

View File

@ -540,6 +540,16 @@ const RecordDecl *ASTContext::addRecordToClass(const ObjCInterfaceDecl *D)
return RD;
}
/// setFieldDecl - maps a field for the given Ivar reference node.
//
void ASTContext::setFieldDecl(const ObjCInterfaceDecl *OI,
const ObjCIvarDecl *Ivar,
const ObjCIvarRefExpr *MRef) {
FieldDecl *FD = (const_cast<ObjCInterfaceDecl *>(OI))->
lookupFieldDeclForIvar(*this, Ivar);
ASTFieldForIvarRef[MRef] = FD;
}
/// getASTObjcInterfaceLayout - Get or compute information about the layout of
/// the specified Objective C, which indicates its size and ivar
/// position information.

View File

@ -1162,7 +1162,7 @@ void ObjCIvarRefExpr::EmitImpl(Serializer& S) const {
ObjCIvarRefExpr* ObjCIvarRefExpr::CreateImpl(Deserializer& D, ASTContext& C) {
SourceLocation Loc = SourceLocation::ReadVal(D);
QualType T = QualType::ReadVal(D);
ObjCIvarRefExpr* dr = new ObjCIvarRefExpr(NULL,NULL,T,Loc);
ObjCIvarRefExpr* dr = new ObjCIvarRefExpr(NULL,T,Loc);
D.ReadPtr(dr->D,false);
return dr;
}

View File

@ -995,8 +995,8 @@ LValue CodeGenFunction::EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E) {
CVRQualifiers = BaseExpr->getType().getCVRQualifiers();
}
return EmitLValueForIvar(BaseValue, E->getDecl(), E->getFieldDecl(),
CVRQualifiers);
return EmitLValueForIvar(BaseValue, E->getDecl(),
getContext().getFieldDecl(E), CVRQualifiers);
}
LValue

View File

@ -275,9 +275,9 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
ParmVarDecl *ArgDecl = OMD->getParamDecl(0);
DeclRefExpr Arg(ArgDecl, ArgDecl->getType(), Loc);
ObjCInterfaceDecl *OI = IMP->getClassInterface();
FieldDecl *FD = OI->lookupFieldDeclForIvar(getContext(), Ivar);
ObjCIvarRefExpr IvarRef(Ivar, FD, Ivar->getType(), Loc, &Base,
ObjCIvarRefExpr IvarRef(Ivar, Ivar->getType(), Loc, &Base,
true, true);
getContext().setFieldDecl(OI, Ivar, &IvarRef);
BinaryOperator Assign(&IvarRef, &Arg, BinaryOperator::Assign,
Ivar->getType(), Loc);
EmitStmt(&Assign);

View File

@ -418,13 +418,14 @@ Sema::ExprResult Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
if (SD == 0 || SD->isDefinedOutsideFunctionOrMethod()) {
ObjCInterfaceDecl *IFace = getCurMethodDecl()->getClassInterface();
if (ObjCIvarDecl *IV = IFace->lookupInstanceVariable(II)) {
FieldDecl *FD = IFace->lookupFieldDeclForIvar(Context, IV);
// FIXME: This should use a new expr for a direct reference, don't turn
// this into Self->ivar, just return a BareIVarExpr or something.
IdentifierInfo &II = Context.Idents.get("self");
ExprResult SelfExpr = ActOnIdentifierExpr(S, Loc, II, false);
return new ObjCIvarRefExpr(IV, FD, IV->getType(), Loc,
static_cast<Expr*>(SelfExpr.Val), true, true);
ObjCIvarRefExpr *MRef= new ObjCIvarRefExpr(IV, IV->getType(), Loc,
static_cast<Expr*>(SelfExpr.Val), true, true);
Context.setFieldDecl(IFace, IV, MRef);
return MRef;
}
}
// Needed to implement property "super.method" notation.
@ -1266,9 +1267,11 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
// (*Obj).ivar.
if (const ObjCInterfaceType *IFTy = BaseType->getAsObjCInterfaceType()) {
if (ObjCIvarDecl *IV = IFTy->getDecl()->lookupInstanceVariable(&Member)) {
FieldDecl *FD = IFTy->getDecl()->lookupFieldDeclForIvar(Context, IV);
return new ObjCIvarRefExpr(IV, FD, IV->getType(), MemberLoc, BaseExpr,
OpKind == tok::arrow);
ObjCIvarRefExpr *MRef= new ObjCIvarRefExpr(IV, IV->getType(), MemberLoc,
BaseExpr,
OpKind == tok::arrow);
Context.setFieldDecl(IFTy->getDecl(), IV, MRef);
return MRef;
}
return Diag(MemberLoc, diag::err_typecheck_member_reference_ivar)
<< IFTy->getDecl()->getDeclName() << &Member