Use of DeclContext for objc's ivars. No functionality
change. More to follow.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72951 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index f4bb895..21aefdd 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -42,6 +42,19 @@
 // ObjCInterfaceDecl
 //===----------------------------------------------------------------------===//
 
+/// getIvarDecl - This method looks up an ivar in this ContextDecl.
+///
+ObjCIvarDecl *
+ObjCContainerDecl::getIvarDecl(ASTContext &Context, IdentifierInfo *Id) const {
+  lookup_const_iterator Ivar, IvarEnd;
+  for (llvm::tie(Ivar, IvarEnd) = lookup(Context, Id);
+       Ivar != IvarEnd; ++Ivar) {
+    if (ObjCIvarDecl *ivar = dyn_cast<ObjCIvarDecl>(*Ivar))
+      return ivar;
+  }
+  return 0;
+}
+
 // Get the local instance method declared in this interface.
 ObjCMethodDecl *
 ObjCContainerDecl::getInstanceMethod(ASTContext &Context, Selector Sel) const {
@@ -139,12 +152,9 @@
   ASTContext &Context, IdentifierInfo *ID, ObjCInterfaceDecl *&clsDeclared) {
   ObjCInterfaceDecl* ClassDecl = this;
   while (ClassDecl != NULL) {
-    for (ivar_iterator I = ClassDecl->ivar_begin(), E = ClassDecl->ivar_end();
-         I != E; ++I) {
-      if ((*I)->getIdentifier() == ID) {
-        clsDeclared = ClassDecl;
-        return *I;
-      }
+    if (ObjCIvarDecl *I = ClassDecl->getIvarDecl(Context, ID)) {
+      clsDeclared = ClassDecl;
+      return I;
     }
     // look into properties.
     for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(Context),