]> granicus.if.org Git - clang/commitdiff
Add a DenseMapInfo specialization for BaseSubobject.
authorAnders Carlsson <andersca@mac.com>
Thu, 14 Jan 2010 01:39:42 +0000 (01:39 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 14 Jan 2010 01:39:42 +0000 (01:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93399 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVtable.h

index b47981412304c5453654d4e16067c5759fc2bbd0..0caaec28169fa062abde5cf531dd9b297d0996d6 100644 (file)
@@ -80,12 +80,47 @@ public:
 
   /// getBaseOffset - Returns the base class offset.
   uint64_t getBaseOffset() const { return BaseOffset; }
-  
+
   friend bool operator==(const BaseSubobject &LHS, const BaseSubobject &RHS) {
     return LHS.Base == RHS.Base && LHS.BaseOffset == RHS.BaseOffset;
  }
 };
-  
+
+} // end namespace CodeGen
+} // end namespace clang
+
+namespace llvm {
+
+template<> struct DenseMapInfo<clang::CodeGen::BaseSubobject> {
+  static clang::CodeGen::BaseSubobject getEmptyKey() {
+    return clang::CodeGen::BaseSubobject(
+      DenseMapInfo<const clang::CXXRecordDecl *>::getEmptyKey(),
+      DenseMapInfo<uint64_t>::getEmptyKey());
+  }
+
+  static clang::CodeGen::BaseSubobject getTombstoneKey() {
+    return clang::CodeGen::BaseSubobject(
+      DenseMapInfo<const clang::CXXRecordDecl *>::getTombstoneKey(),
+      DenseMapInfo<uint64_t>::getTombstoneKey());
+  }
+
+  static unsigned getHashValue(const clang::CodeGen::BaseSubobject &Base) {
+    return 
+      DenseMapInfo<const clang::CXXRecordDecl *>::getHashValue(Base.getBase()) ^
+      DenseMapInfo<uint64_t>::getHashValue(Base.getBaseOffset());
+  }
+
+  static bool isEqual(const clang::CodeGen::BaseSubobject &LHS, 
+                      const clang::CodeGen::BaseSubobject &RHS) {
+    return LHS == RHS;
+  }
+};
+
+}
+
+namespace clang {
+namespace CodeGen {
+
 class CGVtableInfo {
 public:
   typedef std::vector<std::pair<GlobalDecl, ThunkAdjustment> >