diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-12-14 23:59:32 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-12-14 23:59:32 +0000 |
commit | eaa9511dd2bcb0c7f90f47a236a91c82048f484e (patch) | |
tree | 99330474050be2e03fc7ff4e75abe74231f844d9 | |
parent | daaefc5381f9aafbb1cb6f88fb5ac6aaf34d65bf (diff) |
Replace Decl::isSameEntityAs with a free function declaresSameEntity, which can cope with NULL pointer values
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146613 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/DeclBase.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 20f46a4172..b0534b8280 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -589,12 +589,6 @@ public: /// \brief Whether this particular Decl is a canonical one. bool isCanonicalDecl() const { return getCanonicalDecl() == this; } - - /// \brief Determine whether this declaration declares the same entity as - /// the other declaration. - bool isSameEntityAs(const Decl *Other) const { - return getCanonicalDecl() == Other->getCanonicalDecl(); - } protected: /// \brief Returns the next redeclaration or itself if this is the only decl. @@ -766,6 +760,17 @@ protected: ASTMutationListener *getASTMutationListener() const; }; +/// \brief Determine whether two declarations declare the same entity. +inline bool declaresSameEntity(const Decl *D1, const Decl *D2) { + if (D1 == D2) + return true; + + if (!D1 || !D2) + return false; + + return D1->getCanonicalDecl() == D2->getCanonicalDecl(); +} + /// PrettyStackTraceDecl - If a crash occurs, indicate that it happened when /// doing something to a specific decl. class PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry { |