aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjCMac.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-04-22 12:00:04 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-04-22 12:00:04 +0000
commita24357887dc2e6971fb84286be4484953565dc4d (patch)
tree0fecddf04fe327bac32a9c0b34725aa6e2ffdd5d /lib/CodeGen/CGObjCMac.cpp
parent75da6744de692c60e824c02b096aa84dfd993364 (diff)
Remove lookupFieldDeclFromIvar from ObjCIvarDecl interface.
- This is only used by CGObjCRuntime now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69800 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r--lib/CodeGen/CGObjCMac.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index a80274a690..a993963680 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -41,6 +41,22 @@ CGObjCRuntime::GetConcreteClassStruct(CodeGen::CodeGenModule &CGM,
return cast<llvm::StructType>(CGM.getTypes().ConvertTagDeclType(RD));
}
+
+/// LookupFieldDeclForIvar - looks up a field decl in the laid out
+/// storage which matches this 'ivar'.
+///
+static const FieldDecl *LookupFieldDeclForIvar(ASTContext &Context,
+ const ObjCInterfaceDecl *OID,
+ const ObjCIvarDecl *OIVD) {
+ assert(!OID->isForwardDecl() && "Invalid interface decl!");
+ const RecordDecl *RecordForDecl = Context.addRecordToClass(OID);
+ assert(RecordForDecl && "lookupFieldDeclForIvar no storage for class");
+ DeclContext::lookup_const_result Lookup =
+ RecordForDecl->lookup(Context, OIVD->getDeclName());
+ assert((Lookup.first != Lookup.second) && "field decl not found");
+ return cast<FieldDecl>(*Lookup.first);
+}
+
uint64_t CGObjCRuntime::ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM,
const ObjCInterfaceDecl *OID,
const ObjCIvarDecl *Ivar) {
@@ -50,7 +66,7 @@ uint64_t CGObjCRuntime::ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM,
const llvm::StructLayout *Layout =
CGM.getTargetData().getStructLayout(STy);
const FieldDecl *Field =
- OID->lookupFieldDeclForIvar(CGM.getContext(), Ivar);
+ LookupFieldDeclForIvar(CGM.getContext(), OID, Ivar);
if (!Field->isBitField())
return Layout->getElementOffset(CGM.getTypes().getLLVMFieldNo(Field));
@@ -82,7 +98,7 @@ LValue CGObjCRuntime::EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF,
// since the structure layout is fixed; however for that we need to
// be able to walk the class chain for an Ivar.
const FieldDecl *Field =
- OID->lookupFieldDeclForIvar(CGF.CGM.getContext(), Ivar);
+ LookupFieldDeclForIvar(CGF.CGM.getContext(), OID, Ivar);
// (char *) BaseValue
llvm::Type *I8Ptr = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);