Transition the last acceptable-result filter kind in LookupResult over to use
a simple IDNS mask by introducing a namespace for non-member operators.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102215 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index a7a1084..0609eef 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -193,37 +193,6 @@
   };
 }
 
-static bool IsAcceptableIDNS(NamedDecl *D, unsigned IDNS) {
-  return D->isInIdentifierNamespace(IDNS);
-}
-
-static bool IsAcceptableOperatorName(NamedDecl *D, unsigned IDNS) {
-  return D->isInIdentifierNamespace(IDNS) &&
-    !D->getDeclContext()->isRecord();
-}
-
-/// Gets the default result filter for the given lookup.
-static inline
-LookupResult::ResultFilter getResultFilter(Sema::LookupNameKind NameKind) {
-  switch (NameKind) {
-  case Sema::LookupOrdinaryName:
-  case Sema::LookupTagName:
-  case Sema::LookupMemberName:
-  case Sema::LookupRedeclarationWithLinkage: // FIXME: check linkage, scoping
-  case Sema::LookupUsingDeclName:
-  case Sema::LookupObjCProtocolName:
-  case Sema::LookupNestedNameSpecifierName:
-  case Sema::LookupNamespaceName:
-    return &IsAcceptableIDNS;
-
-  case Sema::LookupOperatorName:
-    return &IsAcceptableOperatorName;
-  }
-
-  llvm_unreachable("unkknown lookup kind");
-  return 0;
-}
-
 // Retrieve the set of identifier namespaces that correspond to a
 // specific kind of name lookup.
 static inline unsigned getIDNS(Sema::LookupNameKind NameKind,
@@ -232,7 +201,6 @@
   unsigned IDNS = 0;
   switch (NameKind) {
   case Sema::LookupOrdinaryName:
-  case Sema::LookupOperatorName:
   case Sema::LookupRedeclarationWithLinkage:
     IDNS = Decl::IDNS_Ordinary;
     if (CPlusPlus) {
@@ -241,6 +209,13 @@
     }
     break;
 
+  case Sema::LookupOperatorName:
+    // Operator lookup is its own crazy thing;  it is not the same
+    // as (e.g.) looking up an operator name for redeclaration.
+    assert(!Redeclaration && "cannot do redeclaration operator lookup");
+    IDNS = Decl::IDNS_NonMemberOperator;
+    break;
+
   case Sema::LookupTagName:
     if (CPlusPlus) {
       IDNS = Decl::IDNS_Type;
@@ -287,7 +262,6 @@
   IDNS = getIDNS(LookupKind,
                  SemaRef.getLangOptions().CPlusPlus,
                  isForRedeclaration());
-  IsAcceptableFn = getResultFilter(LookupKind);
 
   // If we're looking for one of the allocation or deallocation
   // operators, make sure that the implicitly-declared new and delete