Carry lookup configuration throughout lookup on the LookupResult.  Give
LookupResult RAII powers to diagnose ambiguity in the results.  Other diagnostics
(e.g. access control and deprecation) will be moved to automatically trigger
during lookup as part of this same mechanism.

This abstraction makes it much easier to encapsulate aliasing declarations
(e.g. using declarations) inside the lookup system:  eventually, lookup will
just produce the aliases in the LookupResult, and the standard access methods
will naturally strip the aliases off.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89027 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 3fcacfc..fdce0e6 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -34,8 +34,8 @@
     TyOrExpr = GetTypeFromParser(TyOrExpr).getAsOpaquePtr();
 
   IdentifierInfo *TypeInfoII = &PP.getIdentifierTable().get("type_info");
-  LookupResult R;
-  LookupQualifiedName(R, StdNamespace, TypeInfoII, LookupTagName);  
+  LookupResult R(*this, TypeInfoII, SourceLocation(), LookupTagName);
+  LookupQualifiedName(R, StdNamespace);
   Decl *TypeInfoDecl = R.getAsSingleDecl(Context);
   RecordDecl *TypeInfoRecordDecl = dyn_cast_or_null<RecordDecl>(TypeInfoDecl);
   if (!TypeInfoRecordDecl)
@@ -567,8 +567,8 @@
                                   DeclarationName Name, Expr** Args,
                                   unsigned NumArgs, DeclContext *Ctx,
                                   bool AllowMissing, FunctionDecl *&Operator) {
-  LookupResult R;
-  LookupQualifiedName(R, Ctx, Name, LookupOrdinaryName);
+  LookupResult R(*this, Name, StartLoc, LookupOrdinaryName);
+  LookupQualifiedName(R, Ctx);
   if (R.empty()) {
     if (AllowMissing)
       return false;
@@ -756,14 +756,12 @@
 bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
                                     DeclarationName Name,
                                     FunctionDecl* &Operator) {
-  LookupResult Found;
+  LookupResult Found(*this, Name, StartLoc, LookupOrdinaryName);
   // Try to find operator delete/operator delete[] in class scope.
-  LookupQualifiedName(Found, RD, Name, LookupOrdinaryName);
+  LookupQualifiedName(Found, RD);
   
-  if (Found.isAmbiguous()) {
-    DiagnoseAmbiguousLookup(Found, Name, StartLoc);
+  if (Found.isAmbiguous())
     return true;
-  }
 
   for (LookupResult::iterator F = Found.begin(), FEnd = Found.end();
        F != FEnd; ++F) {