[cfe-commits] r146613 - /cfe/trunk/include/clang/AST/DeclBase.h

Douglas Gregor dgregor at apple.com
Wed Dec 14 15:59:32 PST 2011


Author: dgregor
Date: Wed Dec 14 17:59:32 2011
New Revision: 146613

URL: http://llvm.org/viewvc/llvm-project?rev=146613&view=rev
Log:
Replace Decl::isSameEntityAs with a free function declaresSameEntity, which can cope with NULL pointer values

Modified:
    cfe/trunk/include/clang/AST/DeclBase.h

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=146613&r1=146612&r2=146613&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Dec 14 17:59:32 2011
@@ -589,12 +589,6 @@
 
   /// \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 @@
   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 {





More information about the cfe-commits mailing list