Some name-lookup-related fixes, from Piotr Rak!

- Changes Lookup*Name functions to return NamedDecls, instead of
Decls. Unfortunately my recent statement that it will simplify lot of
code, was not quite right, but it simplifies some...
- Makes MergeLookupResult SmallPtrSet instead of vector, following
Douglas suggestions.
- Adds %qN format for printing qualified names to Diagnostic.
- Avoids searching for using-directives in Scopes, which are not
DeclScope, during unqualified name lookup.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63739 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index d408def..0c755f6 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -563,7 +563,7 @@
                                                           Loc));
   }
 
-  Decl *D = 0;
+  NamedDecl *D = 0;
   if (Lookup.isAmbiguous()) {
     DiagnoseAmbiguousLookup(Lookup, Name, Loc,
                             SS && SS->isSet() ? SS->getRange()
@@ -627,9 +627,8 @@
   // implicit member ref, because we want a pointer to the member in general,
   // not any specific instance's member.
   if (isAddressOfOperand && SS && !SS->isEmpty() && !HasTrailingLParen) {
-    NamedDecl *ND = dyn_cast<NamedDecl>(D);
     DeclContext *DC = static_cast<DeclContext*>(SS->getScopeRep());
-    if (ND && isa<CXXRecordDecl>(DC)) {
+    if (D && isa<CXXRecordDecl>(DC)) {
       QualType DType;
       if (FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
         DType = FD->getType().getNonReferenceType();
@@ -653,7 +652,7 @@
             }
           }
         }
-        return Owned(BuildDeclRefExpr(ND, DType, Loc, Dependent, Dependent,SS));
+        return Owned(BuildDeclRefExpr(D, DType, Loc, Dependent, Dependent, SS));
       }
     }
   }
@@ -714,7 +713,7 @@
           // Build the implicit member access expression.
           Expr *This = new (Context) CXXThisExpr(SourceLocation(),
                                        MD->getThisType(Context));
-          return Owned(new (Context) MemberExpr(This, true, cast<NamedDecl>(D),
+          return Owned(new (Context) MemberExpr(This, true, D,
                                       SourceLocation(), MemberType));
         }
       }
@@ -1559,7 +1558,7 @@
       = LookupQualifiedName(RDecl, DeclarationName(&Member), 
                             LookupMemberName, false);
 
-    Decl *MemberDecl = 0;
+    NamedDecl *MemberDecl = 0;
     if (!Result)
       return ExprError(Diag(MemberLoc, diag::err_typecheck_no_member)
                << &Member << BaseExpr->getSourceRange());