aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-04-21 01:19:28 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-04-21 01:19:28 +0000
commit525c9b7baeeff022127cd1b167579f3bda73b3ed (patch)
tree324b77cde1dbb39b094ef8dea9287f87bec8987f
parente7d6c3de64009fb13c12f044b606e3d766faa082 (diff)
Kill ASTContext::[gs]etFieldForDecl, instead we just lookup things
when we need them -- which is exactly what some code was already doing! - No intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69648 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ASTContext.h11
-rw-r--r--lib/AST/ASTContext.cpp10
-rw-r--r--lib/CodeGen/CGExpr.cpp6
-rw-r--r--lib/CodeGen/CGObjC.cpp6
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp5
-rw-r--r--lib/CodeGen/CGObjCMac.cpp13
-rw-r--r--lib/CodeGen/CGObjCRuntime.h1
-rw-r--r--lib/CodeGen/CodeGenFunction.h1
-rw-r--r--lib/Sema/SemaExpr.cpp15
9 files changed, 16 insertions, 52 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index 2b95ac57e6..11f629a6f9 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -102,7 +102,6 @@ class ASTContext {
// FIXME: ASTRecordForInterface/ASTFieldForIvarRef and addRecordToClass and
// getFieldDecl be part of the backend (i.e. CodeGenTypes)?
llvm::DenseMap<const ObjCInterfaceDecl*, 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
@@ -507,15 +506,7 @@ public:
const RecordDecl *addRecordToClass(const ObjCInterfaceDecl *D);
void CollectObjCIvars(const ObjCInterfaceDecl *OI,
llvm::SmallVectorImpl<FieldDecl*> &Fields);
- 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
//===--------------------------------------------------------------------===//
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index e266774dde..cfff4b5440 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -18,7 +18,6 @@
#include "clang/AST/Expr.h"
#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/RecordLayout.h"
-#include "clang/AST/ExprObjC.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/StringExtras.h"
@@ -680,15 +679,6 @@ 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) {
- assert(MRef->getDecl() == Ivar);
- ASTFieldForIvarRef[MRef] = OI->lookupFieldDeclForIvar(*this, Ivar);
-}
-
/// getASTObjcInterfaceLayout - Get or compute information about the layout of
/// the specified Objective C, which indicates its size and ivar
/// position information.
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 01bbc84050..906a1e2cd6 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -1137,10 +1137,9 @@ llvm::Value *CodeGenFunction::EmitIvarOffset(ObjCInterfaceDecl *Interface,
LValue CodeGenFunction::EmitLValueForIvar(QualType ObjectTy,
llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
unsigned CVRQualifiers) {
return CGM.getObjCRuntime().EmitObjCValueForIvar(*this, ObjectTy, BaseValue,
- Ivar, Field, CVRQualifiers);
+ Ivar, CVRQualifiers);
}
LValue CodeGenFunction::EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E) {
@@ -1162,8 +1161,7 @@ LValue CodeGenFunction::EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E) {
CVRQualifiers = ObjectTy.getCVRQualifiers();
}
- return EmitLValueForIvar(ObjectTy, BaseValue, E->getDecl(),
- getContext().getFieldDecl(E), CVRQualifiers);
+ return EmitLValueForIvar(ObjectTy, BaseValue, E->getDecl(), CVRQualifiers);
}
LValue
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index e22efa162a..f57a4a0f29 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -195,10 +195,7 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
Types.ConvertType(PD->getType())));
EmitReturnOfRValue(RV, PD->getType());
} else {
- const FieldDecl *Field =
- IMP->getClassInterface()->lookupFieldDeclForIvar(getContext(), Ivar);
- LValue LV = EmitLValueForIvar(TypeOfSelfObject(),
- LoadObjCSelf(), Ivar, Field, 0);
+ LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), Ivar, 0);
if (hasAggregateLLVMType(Ivar->getType())) {
EmitAggregateCopy(ReturnValue, LV.getAddress(), Ivar->getType());
}
@@ -290,7 +287,6 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
ObjCInterfaceDecl *OI = IMP->getClassInterface();
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);
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index 46e20c99ee..167e337386 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -146,7 +146,6 @@ public:
QualType ObjectTy,
llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
unsigned CVRQualifiers);
virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
ObjCInterfaceDecl *Interface,
@@ -1081,9 +1080,9 @@ LValue CGObjCGNU::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
QualType ObjectTy,
llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
unsigned CVRQualifiers) {
- assert(Field == ObjectTy->getAsObjCInterfaceType()->getDecl()->lookupFieldDeclForIvar(CGM.getContext(), Ivar));
+ const ObjCInterfaceDecl *ID = ObjectTy->getAsObjCInterfaceType()->getDecl();
+ const FieldDecl *Field = ID->lookupFieldDeclForIvar(CGM.getContext(), Ivar);
if (Ivar->isBitField())
return CGF.EmitLValueForBitfield(BaseValue, const_cast<FieldDecl *>(Field),
CVRQualifiers);
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 3b5e0c5504..58cfe8e163 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -701,7 +701,6 @@ private:
QualType ObjectTy,
llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
unsigned CVRQualifiers);
virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
ObjCInterfaceDecl *Interface,
@@ -891,7 +890,6 @@ public:
QualType ObjectTy,
llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
unsigned CVRQualifiers);
virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
ObjCInterfaceDecl *Interface,
@@ -2366,9 +2364,9 @@ LValue CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
QualType ObjectTy,
llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
unsigned CVRQualifiers) {
- assert(Field == ObjectTy->getAsObjCInterfaceType()->getDecl()->lookupFieldDeclForIvar(CGM.getContext(), Ivar));
+ const ObjCInterfaceDecl *ID = ObjectTy->getAsObjCInterfaceType()->getDecl();
+ const FieldDecl *Field = ID->lookupFieldDeclForIvar(CGM.getContext(), Ivar);
if (Ivar->isBitField())
return CGF.EmitLValueForBitfield(BaseValue, const_cast<FieldDecl *>(Field),
CVRQualifiers);
@@ -4887,12 +4885,9 @@ LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar(
QualType ObjectTy,
llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
unsigned CVRQualifiers) {
- assert(Field == ObjectTy->getAsObjCInterfaceType()->getDecl()->lookupFieldDeclForIvar(CGM.getContext(), Ivar));
- assert(ObjectTy->isObjCInterfaceType() &&
- "CGObjCNonFragileABIMac::EmitObjCValueForIvar");
- ObjCInterfaceDecl *ID = ObjectTy->getAsObjCInterfaceType()->getDecl();
+ const ObjCInterfaceDecl *ID = ObjectTy->getAsObjCInterfaceType()->getDecl();
+ const FieldDecl *Field = ID->lookupFieldDeclForIvar(CGM.getContext(), Ivar);
llvm::GlobalVariable *IvarOffsetGV = ObjCIvarOffsetVariable(ID, Ivar);
// (char *) BaseValue
diff --git a/lib/CodeGen/CGObjCRuntime.h b/lib/CodeGen/CGObjCRuntime.h
index 262467ae19..4faa89410d 100644
--- a/lib/CodeGen/CGObjCRuntime.h
+++ b/lib/CodeGen/CGObjCRuntime.h
@@ -157,7 +157,6 @@ public:
QualType ObjectTy,
llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
unsigned CVRQualifiers) = 0;
virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
ObjCInterfaceDecl *Interface,
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 91e8695dba..a0f38af42b 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -629,7 +629,6 @@ public:
bool isUnion, unsigned CVRQualifiers);
LValue EmitLValueForIvar(QualType ObjectTy,
llvm::Value* Base, const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
unsigned CVRQualifiers);
LValue EmitLValueForBitfield(llvm::Value* Base, FieldDecl* Field,
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 5abe106bce..788361b59a 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -691,11 +691,10 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
// this into Self->ivar, just return a BareIVarExpr or something.
IdentifierInfo &II = Context.Idents.get("self");
OwningExprResult SelfExpr = ActOnIdentifierExpr(S, Loc, II, false);
- ObjCIvarRefExpr *MRef = new (Context) ObjCIvarRefExpr(IV, IV->getType(),
- Loc, static_cast<Expr*>(SelfExpr.release()),
- true, true);
- Context.setFieldDecl(IFace, IV, MRef);
- return Owned(MRef);
+ return Owned(new (Context)
+ ObjCIvarRefExpr(IV, IV->getType(), Loc,
+ static_cast<Expr*>(SelfExpr.release()),
+ true, true));
}
}
}
@@ -1948,11 +1947,9 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
Diag(MemberLoc, diag::error_protected_ivar_access) << IV->getDeclName();
}
- ObjCIvarRefExpr *MRef= new (Context) ObjCIvarRefExpr(IV, IV->getType(),
+ return Owned(new (Context) ObjCIvarRefExpr(IV, IV->getType(),
MemberLoc, BaseExpr,
- OpKind == tok::arrow);
- Context.setFieldDecl(IFTy->getDecl(), IV, MRef);
- return Owned(MRef);
+ OpKind == tok::arrow));
}
return ExprError(Diag(MemberLoc, diag::err_typecheck_member_reference_ivar)
<< IFTy->getDecl()->getDeclName() << &Member