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/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 5d50d51..a37f3a2 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -677,9 +677,10 @@
     // Look only into the namespace where the friend would be declared to 
     // find a previous declaration. This is the innermost enclosing namespace, 
     // as described in ActOnFriendFunctionDecl.
-    Sema::LookupResult R;
-    SemaRef.LookupQualifiedName(R, DC, Function->getDeclName(), 
-                              Sema::LookupOrdinaryName, true);
+    Sema::LookupResult R(SemaRef, Function->getDeclName(), SourceLocation(),
+                         Sema::LookupOrdinaryName,
+                         Sema::LookupResult::ForRedeclaration);
+    SemaRef.LookupQualifiedName(R, DC);
     
     PrevDecl = R.getAsSingleDecl(SemaRef.Context);
 
@@ -837,8 +838,10 @@
   NamedDecl *PrevDecl = 0;
 
   if (!FunctionTemplate || TemplateParams) {
-    Sema::LookupResult R;
-    SemaRef.LookupQualifiedName(R, Owner, Name, Sema::LookupOrdinaryName, true);
+    Sema::LookupResult R(SemaRef, Name, SourceLocation(),
+                         Sema::LookupOrdinaryName,
+                         Sema::LookupResult::ForRedeclaration);
+    SemaRef.LookupQualifiedName(R, Owner);
     PrevDecl = R.getAsSingleDecl(SemaRef.Context);
 
     // In C++, the previous declaration we find might be a tag type