[cfe-commits] r164862 - /cfe/trunk/include/clang/Sema/ScopeInfo.h

Jordan Rose jordan_rose at apple.com
Fri Sep 28 15:42:04 PDT 2012


Author: jrose
Date: Fri Sep 28 17:42:04 2012
New Revision: 164862

URL: http://llvm.org/viewvc/llvm-project?rev=164862&view=rev
Log:
Use a custom DenseMapInfo for WeakObjectProfileTy.

We can't specialize the usual llvm::DenseMapInfo at the end of the file
because by that point the DenseMap in FunctionScopeInfo has already been
instantiated.

No functionality change.

Modified:
    cfe/trunk/include/clang/Sema/ScopeInfo.h

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=164862&r1=164861&r2=164862&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Fri Sep 28 17:42:04 2012
@@ -160,7 +160,7 @@
     static BaseInfoTy getBaseInfo(const Expr *BaseE);
 
     // For use in DenseMap.
-    friend struct llvm::DenseMapInfo<WeakObjectProfileTy>;
+    friend class DenseMapInfo;
     inline WeakObjectProfileTy();
     static inline WeakObjectProfileTy getSentinel();
 
@@ -189,6 +189,31 @@
     bool operator==(const WeakObjectProfileTy &Other) const {
       return Base == Other.Base && Property == Other.Property;
     }
+
+    // For use in DenseMap.
+    // We can't specialize the usual llvm::DenseMapInfo at the end of the file
+    // because by that point the DenseMap in FunctionScopeInfo has already been
+    // instantiated.
+    class DenseMapInfo {
+    public:
+      static inline WeakObjectProfileTy getEmptyKey() {
+        return WeakObjectProfileTy();
+      }
+      static inline WeakObjectProfileTy getTombstoneKey() {
+        return WeakObjectProfileTy::getSentinel();
+      }
+
+      static unsigned getHashValue(const WeakObjectProfileTy &Val) {
+        typedef std::pair<BaseInfoTy, const NamedDecl *> Pair;
+        return llvm::DenseMapInfo<Pair>::getHashValue(Pair(Val.Base,
+                                                           Val.Property));
+      }
+
+      static bool isEqual(const WeakObjectProfileTy &LHS,
+                          const WeakObjectProfileTy &RHS) {
+        return LHS == RHS;
+      }
+    };
   };
 
   /// Represents a single use of a weak object.
@@ -219,7 +244,8 @@
   /// Used to collect all uses of weak objects in a function body.
   ///
   /// Part of the implementation of -Wrepeated-use-of-weak.
-  typedef llvm::SmallDenseMap<WeakObjectProfileTy, WeakUseVector, 8>
+  typedef llvm::SmallDenseMap<WeakObjectProfileTy, WeakUseVector, 8,
+                              WeakObjectProfileTy::DenseMapInfo>
           WeakObjectUseMap;
 
 private:
@@ -539,26 +565,4 @@
 } // end namespace sema
 } // end namespace clang
 
-namespace llvm {
-  template <>
-  struct DenseMapInfo<clang::sema::FunctionScopeInfo::WeakObjectProfileTy> {
-    typedef clang::sema::FunctionScopeInfo::WeakObjectProfileTy ProfileTy;
-    static inline ProfileTy getEmptyKey() {
-      return ProfileTy();
-    }
-    static inline ProfileTy getTombstoneKey() {
-      return ProfileTy::getSentinel();
-    }
-
-    static unsigned getHashValue(const ProfileTy &Val) {
-      typedef std::pair<ProfileTy::BaseInfoTy, const clang::NamedDecl *> Pair;
-      return DenseMapInfo<Pair>::getHashValue(Pair(Val.Base, Val.Property));
-    }
-
-    static bool isEqual(const ProfileTy &LHS, const ProfileTy &RHS) {
-      return LHS == RHS;
-    }
-  };
-} // end namespace llvm
-
 #endif





More information about the cfe-commits mailing list