]> granicus.if.org Git - clang/commitdiff
Add DeclContext::Equals to compare declaration contexts based on their primary contex...
authorDouglas Gregor <dgregor@apple.com>
Tue, 1 Sep 2009 17:22:34 +0000 (17:22 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 1 Sep 2009 17:22:34 +0000 (17:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80690 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
lib/Sema/IdentifierResolver.cpp

index dcd2482eb3b877977f6e890ef17d5883e1abe128..6e04e553129b2ed4f955d8b7d08bce12b031240f 100644 (file)
@@ -617,6 +617,12 @@ public:
   /// inline namespaces.
   bool isTransparentContext() const;
 
+  /// \brief Determine whether this declaration context is equivalent
+  /// to the declaration context DC.
+  bool Equals(DeclContext *DC) {
+    return this->getPrimaryContext() == DC->getPrimaryContext();
+  }
+  
   /// \brief Determine whether this declaration context encloses the
   /// declaration context DC.
   bool Encloses(DeclContext *DC);
index 1e5fb26fb54073b230f2d504bb7356b5b8f8c6e8..a36b85a87a1e9da0368c10c641db5062e1f22158 100644 (file)
@@ -134,8 +134,7 @@ bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext *Ctx,
     return false;
   }
 
-  return D->getDeclContext()->getLookupContext()->getPrimaryContext() == 
-    Ctx->getPrimaryContext();
+  return D->getDeclContext()->getLookupContext()->Equals(Ctx);
 }
 
 /// AddDecl - Link the decl to its shadowed decl chain.