Revert r102215. This causes clang crash while compiling a test case from gdb testsuite.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102224 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index 0609eef..a7a1084 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -193,6 +193,37 @@
   };
 }
 
+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,
@@ -201,6 +232,7 @@
   unsigned IDNS = 0;
   switch (NameKind) {
   case Sema::LookupOrdinaryName:
+  case Sema::LookupOperatorName:
   case Sema::LookupRedeclarationWithLinkage:
     IDNS = Decl::IDNS_Ordinary;
     if (CPlusPlus) {
@@ -209,13 +241,6 @@
     }
     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;
@@ -262,6 +287,7 @@
   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