From b6d80fe68d30ebd14b20c96643c252c36041df8d Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 28 Sep 2012 22:42:04 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164862 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/ScopeInfo.h | 52 ++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/include/clang/Sema/ScopeInfo.h b/include/clang/Sema/ScopeInfo.h index 6f0fc167d3..0592265ccd 100644 --- a/include/clang/Sema/ScopeInfo.h +++ b/include/clang/Sema/ScopeInfo.h @@ -160,7 +160,7 @@ public: static BaseInfoTy getBaseInfo(const Expr *BaseE); // For use in DenseMap. - friend struct llvm::DenseMapInfo; + friend class DenseMapInfo; inline WeakObjectProfileTy(); static inline WeakObjectProfileTy getSentinel(); @@ -189,6 +189,31 @@ public: 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 Pair; + return llvm::DenseMapInfo::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 @@ public: /// Used to collect all uses of weak objects in a function body. /// /// Part of the implementation of -Wrepeated-use-of-weak. - typedef llvm::SmallDenseMap + typedef llvm::SmallDenseMap WeakObjectUseMap; private: @@ -539,26 +565,4 @@ void FunctionScopeInfo::recordUseOfWeak(const ExprT *E, bool IsRead) { } // end namespace sema } // end namespace clang -namespace llvm { - template <> - struct DenseMapInfo { - 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 Pair; - return DenseMapInfo::getHashValue(Pair(Val.Base, Val.Property)); - } - - static bool isEqual(const ProfileTy &LHS, const ProfileTy &RHS) { - return LHS == RHS; - } - }; -} // end namespace llvm - #endif -- 2.40.0