Rename DeclContext::getLookupContext to getRedeclContext and change its semantics slightly. No functionality change in the absence of inline namespaces. Also, change a few places where inline namespaces actually make a difference to be prepared for them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112563 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 9463b6c..0316124 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -471,8 +471,8 @@
 DeclContext *DeclContext::getLookupParent() {
   // FIXME: Find a better way to identify friends
   if (isa<FunctionDecl>(this))
-    if (getParent()->getLookupContext()->isFileContext() &&
-        getLexicalParent()->getLookupContext()->isRecord())
+    if (getParent()->getRedeclContext()->isFileContext() &&
+        getLexicalParent()->getRedeclContext()->isRecord())
       return getLexicalParent();
   
   return getParent();
@@ -515,7 +515,7 @@
   return false;
 }
 
-bool DeclContext::Encloses(DeclContext *DC) {
+bool DeclContext::Encloses(const DeclContext *DC) const {
   if (getPrimaryContext() != this)
     return getPrimaryContext()->Encloses(DC);
 
@@ -847,10 +847,10 @@
   return const_cast<DeclContext*>(this)->lookup(Name);
 }
 
-DeclContext *DeclContext::getLookupContext() {
+DeclContext *DeclContext::getRedeclContext() {
   DeclContext *Ctx = this;
-  // Skip through transparent contexts.
-  while (Ctx->isTransparentContext())
+  // Skip through transparent contexts, except inline namespaces.
+  while (Ctx->isTransparentContext() && !Ctx->isNamespace())
     Ctx = Ctx->getParent();
   return Ctx;
 }
@@ -863,6 +863,24 @@
   return Ctx->getPrimaryContext();
 }
 
+bool DeclContext::InEnclosingNamespaceSetOf(const DeclContext *O) const {
+  // For non-file contexts, this is equivalent to Equals.
+  if (!isFileContext())
+    return O->Equals(this);
+
+  do {
+    if (O->Equals(this))
+      return true;
+
+    const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(O);
+    if (!NS || !NS->isInline())
+      break;
+    O = NS->getParent();
+  } while (O);
+
+  return false;
+}
+
 void DeclContext::makeDeclVisibleInContext(NamedDecl *D, bool Recoverable) {
   // FIXME: This feels like a hack. Should DeclarationName support
   // template-ids, or is there a better way to keep specializations