summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclObjC.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-04-22 03:45:12 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-04-22 03:45:12 +0000
commit25b81ef84775e5ea9cfd1ad81145203d125940f2 (patch)
treef3f9266a4c2c22c7eb98882a94c1c79d33ddbffd /clang/lib/AST/DeclObjC.cpp
parented462a8d4434d6abb9451a542cfc9621164ea382 (diff)
downloadbcm5719-llvm-25b81ef84775e5ea9cfd1ad81145203d125940f2.tar.gz
bcm5719-llvm-25b81ef84775e5ea9cfd1ad81145203d125940f2.zip
Rework the shadow struct that is layed out for Objective-C classes.
- Superclasses are now always laid out their shadow structure at the first field. - Prior to this, the entire class heirarchy was flattened into a single structure which meant that alignment, padding, and bitfields weren't packed correctly (the ASTRecordLayout was correct however, which meant our debug info didn't coincide with ivar offsets, for example). - This is still very suboptimal, but I believe the ivar layout itself is now at least close to correct. - <rdar://problem/6773388> error: objc[29823]: layout bitmap sliding backwards llvm-svn: 69771
Diffstat (limited to 'clang/lib/AST/DeclObjC.cpp')
-rw-r--r--clang/lib/AST/DeclObjC.cpp28
1 files changed, 23 insertions, 5 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 5df5ff3a7ad..be23e3039d7 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -380,14 +380,32 @@ ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const {
///
const FieldDecl *
ObjCInterfaceDecl::lookupFieldDeclForIvar(ASTContext &Context,
- const ObjCIvarDecl *IVar) const {
+ const ObjCIvarDecl *OIVD) const {
assert(!isForwardDecl() && "Invalid interface decl!");
const RecordDecl *RecordForDecl = Context.addRecordToClass(this);
- assert(RecordForDecl && "lookupFieldDeclForIvar no storage for class");
DeclContext::lookup_const_result Lookup =
- RecordForDecl->lookup(Context, IVar->getDeclName());
- assert((Lookup.first != Lookup.second) && "field decl not found");
- return cast<FieldDecl>(*Lookup.first);
+ RecordForDecl->lookup(Context, OIVD->getDeclName());
+
+ if (Lookup.first != Lookup.second)
+ return cast<FieldDecl>(*Lookup.first);
+
+ // If lookup failed, try the superclass.
+ //
+ // FIXME: This is very non-performant. However, the root problem
+ // here is not the lookup itself. The main issue is that we should
+ // be able to map from an IvarDecl back to the context it lives
+ // inside; then this problem goes away. Currently, however,
+ // IvarDecl's live inside the translation unit!!!!
+ //
+ // Fixing IvarDecl's is less obvious than it might appear, we need
+ // to choose where synthesized ivars should live, and we also need
+ // to decide where to put IvarDecl's which appeared in an
+ // implementation context (either in the situation where they must
+ // duplicate the instance variables, or if there was no instance
+ // declaration).
+ const ObjCInterfaceDecl *OID = getSuperClass();
+ assert(OID && "field decl not found!");
+ return OID->lookupFieldDeclForIvar(Context, OIVD);
}
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud