Patch for ObjCIvarRefExpr containing the field
matching the storage layout for this ivar


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60996 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index e3e4548..f22b5b4 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -363,7 +363,21 @@
   setLocEnd(RBrac);
 }
 
-/// addInstanceVariablesToClass - produces layout info. for the class for its
+/// lookupFieldDeclForIvar - looks up a field decl' in the laid out
+/// storage which matches this 'ivar'.
+///
+FieldDecl *ObjCInterfaceDecl::lookupFieldDeclForIvar(ASTContext &Context, 
+                                                     ObjCIvarDecl *ivar) {
+  assert(RecordForDecl && "lookupFieldDeclForIvar no storage for class");
+  DeclarationName Member = ivar->getDeclName();
+  DeclContext::lookup_result Lookup = RecordForDecl->lookup(Context, Member);
+  assert((Lookup.first != Lookup.second) && "field decl not found");
+  FieldDecl *MemberDecl = dyn_cast<FieldDecl>(*Lookup.first);
+  assert(MemberDecl && "field decl not found");
+  return MemberDecl;
+}
+
+/// addLayoutToClass - produces layout info. for the class for its
 /// ivars and all those inherited.
 ///
 void ObjCInterfaceDecl::addLayoutToClass(ASTContext &Context)