When checking whether one declaration context encloses another, make sure to look at the primary contexts. Thanks to Eli for the test case

llvm-svn: 80212
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 8296f29..cd5b006 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -448,6 +448,16 @@
   return false;
 }
 
+bool DeclContext::Encloses(DeclContext *DC) {
+  if (getPrimaryContext() != this)
+    return getPrimaryContext()->Encloses(DC);
+  
+  for (; DC; DC = DC->getParent())
+    if (DC->getPrimaryContext() == this)
+      return true;
+  return false;  
+}
+
 DeclContext *DeclContext::getPrimaryContext() {
   switch (DeclKind) {
   case Decl::TranslationUnit: