Unifies the name-lookup mechanisms used in various parts of the AST
and separates lexical name lookup from qualified name lookup. In
particular:
  * Make DeclContext the central data structure for storing and
    looking up declarations within existing declarations, e.g., members
    of structs/unions/classes, enumerators in C++0x enums, members of
    C++ namespaces, and (later) members of Objective-C
    interfaces/implementations. DeclContext uses a lazily-constructed
    data structure optimized for fast lookup (array for small contexts,
    hash table for larger contexts). 

  * Implement C++ qualified name lookup in terms of lookup into
    DeclContext.

  * Implement C++ unqualified name lookup in terms of
    qualified+unqualified name lookup (since unqualified lookup is not
    purely lexical in C++!)

  * Limit the use of the chains of declarations stored in
    IdentifierInfo to those names declared lexically.

  * Eliminate CXXFieldDecl, collapsing its behavior into
    FieldDecl. (FieldDecl is now a ScopedDecl).

  * Make RecordDecl into a DeclContext and eliminates its
    Members/NumMembers fields (since one can just iterate through the
    DeclContext to get the fields).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60878 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 8a68d5b..307abe3 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -1955,10 +1955,9 @@
   //        (13.3.1.1.1); otherwise, the set of member candidates is
   //        empty.
   if (const RecordType *T1Rec = T1->getAsRecordType()) {
-    IdentifierResolver::iterator I 
-      = IdResolver.begin(OpName, cast<CXXRecordType>(T1Rec)->getDecl(), 
-                         /*LookInParentCtx=*/false);
-    NamedDecl *MemberOps = (I == IdResolver.end())? 0 : *I;
+    DeclContext::lookup_const_result Lookup 
+      = cast<CXXRecordType>(T1Rec)->getDecl()->lookup(Context, OpName);
+    NamedDecl *MemberOps = (Lookup.first == Lookup.second)? 0 : *Lookup.first;
     if (CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(MemberOps))
       AddMethodCandidate(Method, Args[0], Args+1, NumArgs - 1, CandidateSet,
                          /*SuppressUserConversions=*/false);
@@ -3118,11 +3117,10 @@
   //  ordinary lookup of the name operator() in the context of
   //  (E).operator().
   OverloadCandidateSet CandidateSet;
-  IdentifierResolver::iterator I 
-    = IdResolver.begin(Context.DeclarationNames.getCXXOperatorName(OO_Call), 
-                       cast<CXXRecordType>(Record)->getDecl(), 
-                       /*LookInParentCtx=*/false);
-  NamedDecl *MemberOps = (I == IdResolver.end())? 0 : *I;
+  DeclarationName OpName = Context.DeclarationNames.getCXXOperatorName(OO_Call);
+  DeclContext::lookup_const_result Lookup 
+    = cast<CXXRecordType>(Record)->getDecl()->lookup(Context, OpName);
+  NamedDecl *MemberOps = (Lookup.first == Lookup.second)? 0 : *Lookup.first;
   if (CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(MemberOps))
     AddMethodCandidate(Method, Object, Args, NumArgs, CandidateSet,
                        /*SuppressUserConversions=*/false);
@@ -3315,10 +3313,9 @@
   DeclarationName OpName = Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
   OverloadCandidateSet CandidateSet;
   const RecordType *BaseRecord = Base->getType()->getAsRecordType();
-  IdentifierResolver::iterator I
-    = IdResolver.begin(OpName, cast<CXXRecordType>(BaseRecord)->getDecl(),
-                       /*LookInParentCtx=*/false);
-  NamedDecl *MemberOps = (I == IdResolver.end())? 0 : *I;
+  DeclContext::lookup_const_result Lookup 
+    = cast<CXXRecordType>(BaseRecord)->getDecl()->lookup(Context, OpName);
+  NamedDecl *MemberOps = (Lookup.first == Lookup.second)? 0 : *Lookup.first;
   if (CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(MemberOps))
     AddMethodCandidate(Method, Base, 0, 0, CandidateSet,
                        /*SuppressUserConversions=*/false);