[cfe-commits] r80690 - in /cfe/trunk: include/clang/AST/DeclBase.h lib/Sema/IdentifierResolver.cpp
Douglas Gregor
dgregor at apple.com
Tue Sep 1 10:22:34 PDT 2009
Author: dgregor
Date: Tue Sep 1 12:22:34 2009
New Revision: 80690
URL: http://llvm.org/viewvc/llvm-project?rev=80690&view=rev
Log:
Add DeclContext::Equals to compare declaration contexts based on their primary context. Use this instead of pointer comparisons
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/Sema/IdentifierResolver.cpp
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=80690&r1=80689&r2=80690&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Tue Sep 1 12:22:34 2009
@@ -617,6 +617,12 @@
/// 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);
Modified: cfe/trunk/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.cpp?rev=80690&r1=80689&r2=80690&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Tue Sep 1 12:22:34 2009
@@ -134,8 +134,7 @@
return false;
}
- return D->getDeclContext()->getLookupContext()->getPrimaryContext() ==
- Ctx->getPrimaryContext();
+ return D->getDeclContext()->getLookupContext()->Equals(Ctx);
}
/// AddDecl - Link the decl to its shadowed decl chain.
More information about the cfe-commits
mailing list